- Notifications
You must be signed in to change notification settings - Fork407
Open
Description
Steps to reproduce
# $sb = {Invoke-Command -Session $psSession -ArgumentList $path -ErrorAction Stop -ScriptBlock { Param ($Foo) return $Foo}} # Invoke-ScriptAnalyzer -ScriptDefinition [scriptblock]$sb | ft -aRuleName Severity ScriptName Line Message-------- -------- ---------- ---- -------PSUseUsingScopeModifierInNewRunspaces Warning 3 The variable '$Foo' is not declared within this ScriptBlock, and is missing the 'Using:' scope modifier.PSUseUsingScopeModifierInNewRunspaces Warning 5 The variable '$Foo' is not declared within this ScriptBlock, and is missing the 'Using:' scope modifier.Expected behavior
$Foo should not get flagged
Actual behavior
$Foo is being flagged violating PSUseUsingScopeModifierInNewRunspaces.
Environment data
# $PSVersionTableName Value---------PSVersion5.1.18362.752PSEdition DesktopPSCompatibleVersions {1.0,2.0,3.0,4.0...}BuildVersion10.0.18362.752CLRVersion4.0.30319.42000WSManStackVersion3.0PSRemotingProtocolVersion2.3SerializationVersion1.1.0.1# (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }1.19.0