How can I speed up the Exchange Management Shell launch?

exchangemanagementshell

Have you noticed it takes quite a long time to open up the Exchange command shell? I timed it and it takes anywhere from 20 to 30 seconds to launch.  I found a way to knock this down to 2-3 seconds. This script updates the GAC with some of the Exchange assemblies and makes Command Shell respond well.

1) Paste the following in notepad and save it as Update-shell.ps1 (or whatever name you want):

Set-Alias ngen @(
 dir (join-path ${env:\windir} "Microsoft.NET\Framework64") ngen.exe -recurse |
 sort -descending lastwritetime
 )[0].fullName
 [appdomain]::currentdomain.getassemblies() | %{ngen $_.location}

 

Note: On x86 systems; replace Framework64 in the second line of this script with Framework.

2) [Optional] Close all open windows

3) [Optional] Start the Exchange Management Shell and note the time it takes to start up

4) Run the script: .\Update-shell.ps1 (or whatever you saved it as)

5) Quit all open windows, start the Shell. This fix rocks.