π PowerShell Startup Time
I noticed that PowerShell was taking a long time to start. One common tip is to launch it with the -nologo
:
pwsh -nologo
However, this didnβt make a noticeable difference.
While searching for solutions, I came across this Stack Overflow post:
PowerShell steps to fix slow startup
The post suggests pre-compiling loaded assemblies using ngen.exe
. Hereβs the script it recommends (to be run as Administrator):
$env:PATH = [Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()
[AppDomain]::CurrentDomain.GetAssemblies() | ForEach-Object {
$path = $_.Location
if ($path) {
$name = Split-Path $path -Leaf
Write-Host -ForegroundColor Yellow "`r`nRunning ngen.exe on '$name'"
ngen.exe install $path /nologo
}
}
When I tried this, I got an error saying ngen.exe
was not found. It turns out ngen.exe
is included with Visual Studio. So I launched a Developer PowerShell from Visual Studio and ran the script there.
After doing this, PowerShell startup (especially with -nologo
) became noticeably faster.