为什么 Powershell 初始化需要这么长时间?

squ*_*man 20 powershell

当我启动 powershell 时,它需要大约 10-15 秒的时间来初始化并给我一个提示。有谁知道当你第一次启动它时它在做什么可能会导致它?这是 XP Pro,2 GB 内存,只有 Outlook 和 Firefox 交互运行,相当直接。

aha*_*den 15

Powershell 团队在他们的博客上对此进行修复

来自该站点的脚本内容提到 Update-gac.ps1

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$_"}
         }
      }
Run Code Online (Sandbox Code Playgroud)