PSScriptAnalyzer
PSScriptAnalyzer copied to clipboard
PSScriptAnalyzer incorrectly scopes variables in begin/process/end scriptblock
PSScriptAnalyzer incorrectly adds scope to begin/process/end scriptblocks when it should treat them as one scope:

This also happens in the ForEach method:
$Script = @'
$A = @()
(1..2).ForEach{ $A += $_ }
$A
'@
Invoke-ScriptAnalyzer -ScriptDefinition $Script | Select -ExpandProperty Message
The variable 'A' is assigned but never used.
Bug still exists today and it is very annoying.