Posted by: kurtsh | July 15, 2008

INFO: Speeding up PowerShell v1 startup times

image <taken from the PowerShell team blog>
Jeffery Snover of the PowerShell team blog wrote a rather interesting article highlighting how to drastically improve the performance of PowerShell v1.0’s startup times.

WHAT IS THIS?
The net of it is that he runs the following script and the result is much improved startup times for anything initially executed in PowerShell. 

Note that you will need administrator access to run the script below.

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

WHAT ABOUT x64?
The script is just a little different for x64 with “Microsoft.NETFramework” being replaced by “Microsoft.NETFramework64”.

WHAT ABOUT POWERSHELL v2.0?
The problem will be fixed in Powershell 2.0 so this is specific to v1.0.


Categories

%d bloggers like this: