3

Since May 2019 Security Rollup for Windows Server 2016, access to .net object via powershell is very slow, when a powershell variable breakpoint is set in the powershell.

For example loading speed of [System.Environment] takes over ten times with breakpoint set against no breakpoint set.

Since the behavior only occurs with latest security updates installed (May 2019 (KB4494440) or June 2019 (KB4503267)) i think it is related to the update.

Did some troubleshooting with procmon until now. For me it looks like when PSBreakpoint is set, there are multiple reads from HKLM\System\CurrentControlSet\Control\Session Manager\Environment\__PSLockdownPolicy can't repoduce this when there is no breakpoint set and can't reproduce this effect without one of the updates installed.

Following powershell code runs more than 10 times slower when i install Windows Security Rollup update Mai / June 2019 on my Windows Server 2016.

$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

Can anyone observe this behavior as well?

Do you have any suggestions to workaround this problem?

Is it related to some settings or installed software?

fadanner
  • 158
  • 1
  • 8
  • It sounds like you should file an issue on the MS PowerShell GitHub repo. – Ian Kemp Jun 13 '19 at 12:37
  • I don't have Server 2016, but on other machines, after a Windows update when things start to go slow, it helps running [Ngen.exe](https://learn.microsoft.com/en-us/dotnet/framework/tools/ngen-exe-native-image-generator) – Theo Jun 13 '19 at 12:57
  • Windows 10, Powershell **5.1**: `0.0109209 / 3.2646145`, Powershell **6.2**: `0.0052287 / 0.0078765` – JosefZ Jun 13 '19 at 15:34

0 Answers0