diff --git a/Engine/Helper.cs b/Engine/Helper.cs index 66105b1b3..966876051 100644 --- a/Engine/Helper.cs +++ b/Engine/Helper.cs @@ -315,7 +315,7 @@ public bool PositionalParameterUsed(CommandAst cmdAst) /// /// /// - public CommandInfo GetCommandInfo(string name, CommandTypes commandType = CommandTypes.All) + public CommandInfo GetCommandInfo(string name, CommandTypes commandType = CommandTypes.Alias | CommandTypes.Cmdlet | CommandTypes.Configuration | CommandTypes.ExternalScript | CommandTypes.Filter | CommandTypes.Function | CommandTypes.Script | CommandTypes.Workflow) { return Helper.Instance.MyCmdlet.InvokeCommand.GetCommand(name, commandType); } diff --git a/Tests/Rules/AvoidPositionalParametersNoViolations.ps1 b/Tests/Rules/AvoidPositionalParametersNoViolations.ps1 index 41562ffd8..874ef0bd7 100644 --- a/Tests/Rules/AvoidPositionalParametersNoViolations.ps1 +++ b/Tests/Rules/AvoidPositionalParametersNoViolations.ps1 @@ -4,4 +4,13 @@ Clear-Host Split-Path -Path "Random" -leaf Get-Process | Where-Object {$_.handles -gt 200} get-service-computername localhost | where {($_.status -eq "Running") -and ($_.CanStop -eq $true)} -1, 2, $null, 4 | ForEach-Object {"Hello"} \ No newline at end of file +1, 2, $null, 4 | ForEach-Object {"Hello"} +& "$env:Windir\System32\Calc.exe" Parameter1 Parameter2 + +# There was a bug in Positional Parameter rule that resulted in the rule being fired +# when using external application with absolute paths +# The below function is to validate the fix - rule must not get triggered +function TestExternalApplication +{ + & "c:\Windows\System32\Calc.exe" parameter1 +} \ No newline at end of file