diff --git a/Engine/Helper.cs b/Engine/Helper.cs index 78e43dc2a..8fcae65f9 100644 --- a/Engine/Helper.cs +++ b/Engine/Helper.cs @@ -353,7 +353,8 @@ public bool PositionalParameterUsed(CommandAst cmdAst, bool moreThanThreePositio arguments += 1; } - if (moreThanThreePositional && arguments < 3) + // if we are only checking for 3 or more positional parameters, check that arguments < parameters + 3 + if (moreThanThreePositional && (arguments - parameters) < 3) { return false; } diff --git a/Tests/Rules/AvoidPositionalParametersNoViolations.ps1 b/Tests/Rules/AvoidPositionalParametersNoViolations.ps1 index 1c3841846..9a5cc7d75 100644 --- a/Tests/Rules/AvoidPositionalParametersNoViolations.ps1 +++ b/Tests/Rules/AvoidPositionalParametersNoViolations.ps1 @@ -20,4 +20,6 @@ Get-Content Test Get-ChildItem Tests Write-Output "I don't want to use positional parameters" Split-Path "RandomPath" -Leaf -Get-Process | ForEach-Object {Write-Host $_.name -foregroundcolor cyan} \ No newline at end of file +Get-Process | ForEach-Object {Write-Host $_.name -foregroundcolor cyan} + +$srvc = Get-WmiObject Win32_Service -ComputerName $computername -Filter "name=""$service""" -Credential $credential \ No newline at end of file