To start off, this is directly from VS Code, I havent tested it anywhere else or in any other way. VS Code: 1.24.1 Powershell plugin: 1.7.0 A simple statement like this $collection | %{ $myVar = 0 }{ $myvar += $_}{$myVar} obviously this is a worthless bit of code, however it complains that myVar is declared but never used.