Thursday, July 10, 2008

Windows PowerShell : Update-Gac.ps1

 

Update-Gac.ps1

Below is the content of the Update-GAC.ps1 script that I run whenever I install a new version of PowerShell. Our installation is supposed to ngen the assemblies in the background. If that works, it doesn't work fast enough for me. Also I've seen lots of examples where people run this script long after their install and things get a TON faster so …. The install team is looking into the issue but until then – here is the script I use:

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

Cheers!

Jeffrey Snover [MSFT]
Windows Management Partner Architect

Windows PowerShell : Update-Gac.ps1

No comments: