2

Please I am trying to pass a html string as value to the below powershell function "set-content" from azure cli but I don't think I am escaping the double quotes correctly. The value parameter only accepts strings, somehow, it does not get executed at the target machine with the double quote. I get the below error. please help!

az vm extension set --name CustomScriptExtension --vm-name MyWindowsVM -g TestsandRG --publisher Microsoft.Compute --settings '{"commandToExecute": "powershell set-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value \"<html><body><h2>Welcome to Azure! My name is $($env:computername) .<\/h2><\/body><\/html>\""}'

enter image description here

Joey
  • 344,408
  • 85
  • 689
  • 683
kossy tony
  • 21
  • 2
  • 1
    Sadly, when calling from PowerShell, you must additionally `\ `-escape the embedded `"` chars., even though that shouldn't be necessary: see https://stackoverflow.com/a/51861924/45375 and https://stackoverflow.com/a/59036879/45375 – mklement0 Oct 03 '20 at 22:00

0 Answers0