@@ -61,12 +61,12 @@ function GetCommandAlias {
6161 $isGlobal = $false
6262
6363 # Evaluate if the command uses named parameter Scope set to Global. Always start at second element.
64- 1 .. ( $ aliasCommandAst.CommandElements.Count - 1 ) | ForEach-Object - Process {
65- if ($aliasCommandAst.CommandElements [$_ ] -is [System.Management.Automation.Language.CommandParameterAst ] `
66- -and $aliasCommandAst.CommandElements [$_ ].ParameterName -eq ' Scope'
64+ for ( $i = 1 ; $i -lt $ aliasCommandAst.CommandElements.Count - 1 ; $i ++ ) {
65+ if ($aliasCommandAst.CommandElements [$i ] -is [System.Management.Automation.Language.CommandParameterAst ] `
66+ -and $aliasCommandAst.CommandElements [$i ].ParameterName -eq ' Scope'
6767 ) {
6868 # Value (the scope) is in the next item in the array.
69- if ($aliasCommandAst.CommandElements [$_ + 1 ].Value -imatch ' Global' ) {
69+ if ($aliasCommandAst.CommandElements [$i + 1 ].Value -ieq ' Global' ) {
7070 $isGlobal = $true
7171 }
7272 }
@@ -81,12 +81,12 @@ function GetCommandAlias {
8181 $aliasName = $aliasCommandAst.CommandElements [1 ].Value
8282 } else {
8383 # Evaluate if the command uses named parameter Name. Always start at second element.
84- 1 .. ( $ aliasCommandAst.CommandElements.Count - 1 ) | ForEach-Object - Process {
85- if ($aliasCommandAst.CommandElements [$_ ] -is [System.Management.Automation.Language.CommandParameterAst ] `
86- -and $aliasCommandAst.CommandElements [$_ ].ParameterName -eq ' Name'
84+ for ( $i = 1 ; $i -lt $ aliasCommandAst.CommandElements.Count - 1 ; $i ++ ) {
85+ if ($aliasCommandAst.CommandElements [$i ] -is [System.Management.Automation.Language.CommandParameterAst ] `
86+ -and $aliasCommandAst.CommandElements [$i ].ParameterName -eq ' Name'
8787 ) {
8888 # Value (the alias name) is in the next item in the array.
89- $aliasName = $aliasCommandAst.CommandElements [$_ + 1 ].Value
89+ $aliasName = $aliasCommandAst.CommandElements [$i + 1 ].Value
9090 }
9191 }
9292 }
0 commit comments