Answers:
PowerShell依赖于 .NET Framework,您可以尝试对其进行更新。
这个脚本也帮助我提高了速度
$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
}
Generate native images for an assembly and its dependencies and install them in the Native Images Cache. If /queue is specified compilation job is queued up. If a priority is not specified, the default priority used is 3.
Powershell配置文件可以存储几个不同的默认位置。
第一个位置是全局位置,当您希望所有用户都具有自定义的Powershell配置文件时将很有用。此配置文件应放置在
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Profile.ps1
第二个位置用于本地配置文件,并且特定于每个用户帐户。该文件将覆盖全局配置文件,应放置在
C:\Username\My Documents\WindowsPowerShell\Profile.ps1
作为测试,请尝试修改全局Powershell配置文件(位于system32中),看看是否可以加快速度。如果是这样,您会知道网络速度慢是由于某种原因,您可以从那里继续前进。
最近,在开发二进制PowerShell模块时遇到了类似的问题。我的控制台对几乎所有内容的响应都非常慢。史蒂文·潘尼(Steven Penny)的脚本对我有用,但仅适用于PowerShell的每个实例。我不太了解他的剧本里发生了什么。所以我逐行去看看我的问题在哪里。
最终是我的路径环境变量。我在我的path变量中有UNC路径字符串,并且造成了延迟,因为PowerShell将为每次执行打开/关闭连接(即,每次按Enter键)。