azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

"az vm user update" fails in PowerShell if new password contains ampersand

Open alex-slover opened this issue 7 years ago • 1 comments

Describe the bug

Command Name az vm user update

Errors:

After printing the first JSON blob for enablevmaccess, the console writes

'foo' is not recognized as an internal or external command, operable program or batch file.

where foo is the part of the new password after the ampersand. It seems that the shell is interpreting the ampersand and trying to run the remaining part as a command.

To Reproduce:

  • az vm user update -n $vmName -g $resourceGroup -u $userName -p $newPw where $newPw contains an & character

Expected Behavior

Password should be changed successfully.

Environment Summary

Windows-10-10.0.18362-SP0 (build 1903)
Python 3.6.6
Shell: powershell.exe (5.1.18362.113)

azure-cli 2.0.65 (installed via MSI)

Additional Context

alex-slover avatar May 22 '19 18:05 alex-slover

You need to escape the & character because it is interpreted by the Powershell shell before it ever reaches the CLI. There is nothing that can be done in the CLI about this.

tjprescott avatar May 23 '19 15:05 tjprescott