Skip to content

Commit 1b84fda

Browse files
committed
Merge pull request #281 from PowerShell/BugFixes
Take Bug fixes to Master
2 parents a2f92d3 + eec0a36 commit 1b84fda

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Engine/Helper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public bool PositionalParameterUsed(CommandAst cmdAst)
315315
/// <param name="name"></param>
316316
/// <param name="commandType"></param>
317317
/// <returns></returns>
318-
public CommandInfo GetCommandInfo(string name, CommandTypes commandType = CommandTypes.All)
318+
public CommandInfo GetCommandInfo(string name, CommandTypes commandType = CommandTypes.Alias | CommandTypes.Cmdlet | CommandTypes.Configuration | CommandTypes.ExternalScript | CommandTypes.Filter | CommandTypes.Function | CommandTypes.Script | CommandTypes.Workflow)
319319
{
320320
return Helper.Instance.MyCmdlet.InvokeCommand.GetCommand(name, commandType);
321321
}

Tests/Rules/AvoidPositionalParametersNoViolations.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,13 @@ Clear-Host
44
Split-Path -Path "Random" -leaf
55
Get-Process | Where-Object {$_.handles -gt 200}
66
get-service-computername localhost | where {($_.status -eq "Running") -and ($_.CanStop -eq $true)}
7-
1, 2, $null, 4 | ForEach-Object {"Hello"}
7+
1, 2, $null, 4 | ForEach-Object {"Hello"}
8+
& "$env:Windir\System32\Calc.exe" Parameter1 Parameter2
9+
10+
# There was a bug in Positional Parameter rule that resulted in the rule being fired
11+
# when using external application with absolute paths
12+
# The below function is to validate the fix - rule must not get triggered
13+
function TestExternalApplication
14+
{
15+
& "c:\Windows\System32\Calc.exe" parameter1
16+
}

0 commit comments

Comments
 (0)