Powershell very slow to open/respond

Solution 1:

PowerShell relies on the .NET Framework, you can try updating that.

This script also helped my speed

$Env:PATH = [Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()
[AppDomain]::CurrentDomain.GetAssemblies() | % {
  $pt = $_.Location
  if (! $pt) {continue}
  if ($cn++) {''}
  $na = Split-Path -Leaf $pt
  Write-Host -ForegroundColor Yellow "NGENing $na"
  ngen install $pt
}

Solution 2:

The above answer that talks about NGEN reduced my startup time from over 30 seconds, to under 5.

However I have also seen cases where hitting Ctrl-C after waiting a few seconds gets me to a prompt, and I already did the NGEN trick above, and in that case, I suspect it's my scripts that are slowing me down.

If it's over 30 seconds, and you already tried the NGEN trick above, the most common reason is that your personal and system profile powershell scripts are taking a long time to start. If you're complaining about a delay less than 10 seconds, then it's probably .net which is slow to start.

If you're on a VM and the VM host is totally hogtied and IO-bound like most over-provisioned and under-resourced VM environments are, then it's that.