More on Update-GAC (speeding up PowerShell startup)

Jeffrey Snover of Microsoft, PowerShell dude extraordinaire, recently reminded us of a way to Speed Up PowerShell Startup times, based on an article of over a year ago titled Update-Gac.ps1. And yes, this does help to speed up the Exchange Management Shell and the OpsMgr Command Shell too.

Taking that just a bit further, the assemblies you want to put into the GAC are slightly different when you are running AMD-64 (AMD) or EMT-64 (intel). Here is the script updated to deal with x64 and to suppress the ngen logo:

Set-Alias ngen @(
$ngen_path = Join-Path ${env:\windir} "Microsoft.NET\Framework"
$ptr_width = (gwmi -query "select addresswidth from win32_processor").addresswidth
if ($ptr_width -eq 64) { $ngen_path += "64"; }
dir $ngen_path ngen.exe -recurse | where {$_.length -gt 0} | sort -descending lastwritetime 

[appdomain]::currentdomain.getassemblies() | %{ngen /nologo $_.location}

You should execute this script once on each computer where you have PowerShell installed (or each time you install new PowerShell related binaries, too!).

You will not need to do this in PowerShell v2, but that is still not here yet. 

Until next time...

As always, if there are items you would like me to talk about, please drop me a line and let me know!

Published Friday, July 25, 2008 12:00 PM by michael
Filed under: , ,


Saturday, August 02, 2008 1:22 AM by subject: exchange

# Weekend reading

SBS - Exchange Information Store is Corrupt? Recreating the Store Microsoft Exchange Online Beta Performs

Friday, August 08, 2008 5:54 AM by Matt Johnson's Technical Adventures

# Interesting Links – 8/8/2008

You Had Me At EHLO... : Understanding Exchange 2007 Memory Usage and its use of the Paging File