question

VedanthPulipati-4457 avatar image
0 Votes"
VedanthPulipati-4457 asked smfx answered

while trying to run the az run command with the powershell script but facing an error

i am trying to run the below az run command but facing the error

command :

az vm run-command invoke --command-id RunPowerShellScript -g "XXXXXX" -n "XXXX" --scripts "winrm set winrm/config/service/auth '@{Kerberos="true"}'"


error:
200865-image.png


windows-serverwindows-server-powershellazure-virtual-machines
image.png (48.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

deherman-MSFT avatar image
0 Votes"
deherman-MSFT answered

@VedanthPulipati-4457

I understand you are trying to use RunPowerShellScript from azure CLI but it is failing.

I believe the issue is with the quotations inside your script. You can see Quoting issues with PowerShell page for more explicit info. I was able to run the command via Portal without issue.
201146-image.png

You don't need to worry about escaping characters if running the script from a file.
201175-image.png

Please give this a try to see if it works for you. Let me know if you are still running into issues.



Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


image.png (86.5 KiB)
image.png (35.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

smfx avatar image
2 Votes"
smfx answered

Hi @VedanthPulipati-4457 ! @deherman-MSFT is right that it is the quotes that is probably giving you issues. Both of his solutions should work, but if you need to have it in inline on your PowerShell, its the double-quotes (") specifically causing problems and you can escape them in PowerShell by doubling up on your double-quotes (""):

 az vm run-command invoke --command-id RunPowerShellScript -g "XXXXXX" -n "XXXX" --scripts "winrm set winrm/config/service/auth '@{Kerberos=""true""}'"
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.