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?