Skip to content

Instantly share code, notes, and snippets.

@avin
Created March 15, 2015 12:54
Show Gist options
  • Save avin/532050e0937becc25fd4 to your computer and use it in GitHub Desktop.
Save avin/532050e0937becc25fd4 to your computer and use it in GitHub Desktop.
Speeding Up PowerShell Startup
Set-Alias ngen (Join-Path ([System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()) ngen.exe)
[AppDomain]::CurrentDomain.GetAssemblies() |
sort {Split-path $_.location -leaf} |
%{
$Name = (Split-Path $_.location -leaf)
if ([System.Runtime.InteropServices.RuntimeEnvironment]::FromGlobalAccessCache($_))
{
Write-Host "Already GACed: $Name"
}else
{
Write-Host -ForegroundColor Yellow "NGENing : $Name"
ngen $_.location | %{"`t$_"}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment