自2019年4月MS安全更新以来,Powershell.net代码运行缓慢

自2019年4月MS安全更新以来,Powershell.net代码运行缓慢,.net,powershell,windows-server-2016,windows-update,.net,Powershell,Windows Server 2016,Windows Update,自2019年5月Windows Server 2016安全汇总以来,当在powershell中设置powershell变量断点时,通过powershell访问.net对象的速度非常慢 例如,[System.Environment]的加载速度在设置断点时超过10倍,而在未设置断点时则超过10倍 由于这种行为只发生在安装了最新安全更新(2019年5月(KB4494440)或2019年6月(KB4503267))的情况下,我认为它与更新有关 到目前为止,我一直在使用procmon进行故障排除。对我来说

自2019年5月Windows Server 2016安全汇总以来,当在powershell中设置powershell变量断点时,通过powershell访问.net对象的速度非常慢

例如,[System.Environment]的加载速度在设置断点时超过10倍,而在未设置断点时则超过10倍

由于这种行为只发生在安装了最新安全更新(2019年5月(KB4494440)或2019年6月(KB4503267))的情况下,我认为它与更新有关

到目前为止,我一直在使用procmon进行故障排除。对我来说,设置PSBreakpoint时,从
HKLM\System\CurrentControlSet\Control\Session Manager\Environment\\uu PSLockdownPolicy
进行多次读取时,如果没有设置断点,则无法重新产生此效果,并且在未安装任何更新的情况下也无法再现此效果

在我于2019年6月在Windows Server 2016上安装Windows安全汇总更新Mai时,以下powershell代码的运行速度要慢10倍以上

$measure1 = measure-command{
  foreach($i in 1..10000){
    [System.Environment]
  }
} |select -ExpandProperty TotalSeconds

Set-PSBreakpoint -Variable "test" -Action {$null}

$measure2 = measure-command{
  foreach($i in 1..10000){
    [System.Environment]
  }
} |select -ExpandProperty TotalSeconds

Write-Host "First measurement took $measure1 seconds, Second measurement took $measure2"

>>First measurement took 0.0482474 seconds, Second measurement took 0.8722697
有人也能观察到这种行为吗

你对解决这个问题有什么建议吗


它与某些设置或安装的软件有关吗?

听起来您应该在MS PowerShell GitHub repo上提交一个问题。我没有Server 2016,但在其他机器上,在Windows更新后,当事情开始变慢时,它有助于运行Windows 10、PowerShell 5.1:
0.0109209/3.2646145
,Powershell 6.2:
0.0052287/0.0078765