Closed
Description
System Details
- Windows 10 1511
- VS Code Version: 1.14.2
- PowerShell extension version: 1.4.1
- $PSVersionTable
PSVersion 5.0.10586.962
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.962
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Description
When a variable is declared either in the begin block or statement block of a ForEach-Object pipeline, the PSScriptAnalyzer incorrectly flags it as assigned but never used.
Examples:
$Count is incorreclty flagged as assigned but never used
$myArray = @()
$myArray += "Item1"
$myArray += "Item2"
$myArray += "Item3"
$myArray += "Item4"
$myArray | ForEach-Object {$Count = 0} {$Count++; $Count}
Metadata
Metadata
Assignees
Labels
No labels