AZ CLI 2.40 on Windows Powershell fails to run '&' invocation operator with parameters
See original GitHub issue
az feedback
auto-generates most of the information requested below, as of CLI version 2.0.62
Related command
Any AZ command with arguments using an invocation operator.
Describe the bug In PowerShell on Windows, with CLI 2.40, using PS 5.2, 7.2.6 or 7.3.preview7, all versions fail to run script blocks with the invocation (call) operator ‘&’ and passing an arguments array. It looks like parsing is not done correctly and could be linked to this article https://github.com/Azure/azure-cli/blob/dev/doc/quoting-issues-with-powershell.md
To Reproduce Try out a block like this in your PowerShell terminal, the result is Azure CLI returning an error that the ‘account show’ is misspelled or cmdlet not found.
$arglist = @("account", "show")
& "az" $arglist
Expected behavior The expected behavior is that ‘az account show’ should be executed and the result of the JSON shown on screen.
Environment summary OS: Windows 11 insider build PowerShell 7.2.6 AZ CLI: 2.40
I also tested this on PowerShell in CloudShell and there it runs as expected. Als on PowerShell on Linux WSL2 it works fine, both using Azure CLI 2.40. It seems the issue is only arising on Windows.
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:11
Top GitHub Comments
The next version will revert that change and will be shipped on 10.12
@yonzhan will this be done in such a way that the workaround mentioned in this thread will still work? So both these snippets would perform the same:
and
Example courtesy of @Jawz84