You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PSAvoidUsingPositionalParameters reports issue with az command when version 2.40.0 of az cli is installed #1845
Version 2.40.0 of the az cli included this addition that replaced the previous executable with an entry script, az.ps1. Now because it's an "ExternalScript" it triggers the PSAvoidUsingPositionalParameters rule, even though they're not "PowerShell" parameters and az isn't really a "PowerShell" script in the sense that it has named and positional parameters.
Steps to reproduce
Install az cli 2.40.0
Create a file az-test.ps1 with the following line
az account management-group create --name $name--display-name $displayName--parent $parent
Run Invoke-ScriptAnalyzer against it
Invoke-ScriptAnalyzer .\az-test.ps1
Expected behavior
No output, as no issues are detected
Actual behavior
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidUsingPositionalParameters Information az-test.ps 1 Cmdlet 'az' has positional parameter. Please use named
1 parameters instead of positional parameters when calling a
command.
I've also tested this with PS 7.2.6 and gotten the same result. This is a weird "bug" because everything is doing what it's supposed to on a surface level, it's just that all this "correct" behavior has intersected to cause overall incorrect behavior. Maybe it just shouldn't check external scripts? Or maybe the az cli is popular enough that an exception can be made directly where PSSA won't test calls to az.ps1?
Opened a PR with a fix and since we are close to releasing a new version, hope to get this out very soon. In the meantime you could suppress az specifically using [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingPositionalParameters', 'az')]
Activity
bergmeister commentedon Sep 20, 2022
Thanks for calling this out, it might be worth an exception.
bergmeister commentedon Sep 22, 2022
Opened a PR with a fix and since we are close to releasing a new version, hope to get this out very soon. In the meantime you could suppress az specifically using
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingPositionalParameters', 'az')]bergmeister commentedon Sep 29, 2022
Peter Bajurny (@FISHMANPET) This fix has been release in 1.21.0 to the PowerShellGallery now: https://github.com/PowerShell/PSScriptAnalyzer/releases/tag/1.21.0