@Benjamin Balanger Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
I see that you are trying to invoke the VM RunCommand REST API and want to see the output response returned.
Please note that the output response for the above REST API would look like below:
Note that the status code is 202, which means Accepted. This being an ASYNC operation it will send a Location response header. This Location header url needs to be invoked again in subsequent request inorder to get the desired output. And this is by-design.
So to simplify this process, the easiest way is to run the Invoke-AzVMRunCommand PowerShell cmdlet, this makes the same above REST API call underneath. Also this will query the Location header in subsequent request the background and will eventually display the desired output. See the below sample script and its corresponding output:
PS script:
Invoke-AzVMRunCommand -ResourceGroupName 'rgname' -VMName 'vmname' -CommandId 'RunPowerShellScript' -ScriptPath 'sample.ps1' -Parameter @{param1 = "var1"; param2 = "var2"}
Response received:
See the Message value in the response for the desired output from the script.
Value[0] :
Code : ComponentStatus/StdOut/succeeded
Level : Info
DisplayStatus : Provisioning succeeded
Message :
hello World response from my sample script
From Sample Script..
Value[1] :
Code : ComponentStatus/StdErr/succeeded
Level : Info
DisplayStatus : Provisioning succeeded
Message :
Status : Succeeded
Capacity : 0
Count : 0
Hope this helps.
**
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.