Sunday, December 29, 2013

Make PowerShell startup blazing fast!!

If you use PowerShell...You HAVE to run this script! This will cut the time it takes PowerShell to start in half!

Function Improve-GAC { 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$_"}
         }
      }
}Improve-GAC


referance: http://blogs.msdn.com/b/powershell/archive/2007/11/08/update-gac-ps1.aspx