question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created a year ago
  • Reactions:7
  • Comments:11

github_iconTop GitHub Comments

4reactions
yonzhancommented, Oct 4, 2022

The next version will revert that change and will be shipped on 10.12

1reaction
EmilDamsbocommented, Oct 4, 2022

@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:

$env:AZ_INSTALLER="MSI"
& "$PSScriptRoot\..\python.exe" -IBm azure.cli $args

and

$env:AZ_INSTALLER="MSI"
& "$PSScriptRoot\..\python.exe" -IBm azure.cli @args  # notice the @ instead of the $ here with @args

Example courtesy of @Jawz84

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invoking AZ CLI commands within powershell script in Azure ...
Hi Guys,. Is it possible to run a AZ Cli command within my powershell runbook in Azure? From Azure cloud shell i am...
Read more >
Release notes & updates – Azure CLI - Microsoft Learn
Learn about the latest Azure Command-Line Interface (CLI) release notes and updates for both the current and beta versions of the CLI.
Read more >
Azure PowerShell release notes - Microsoft Learn
Customers can use Invoke-AzStackHciConnectivityValidation from the module AzStackHCI.EnvironmentChecker for connectivity verification tests.
Read more >
Use deployment scripts in Bicep - Azure Resource Manager
Currently, Azure PowerShell and Azure CLI deployment scripts on the ... Scripts splits the arguments into an array of strings by invoking ......
Read more >
Troubleshooting the Azure Az PowerShell module
This message occurs when you have both the Az and AzureRM PowerShell modules installed on the same Windows-based system and they exist in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found