I have a .NET application that I use to execute PS commandlets on an Azure VMSS instance. To do so, I use the RunPowershellScript commandId and send it over an HTTP Request to the VMSS instance.
A simple script like this works –
string script = string.Format(
"$script = @(" +
"Write-Host Hello {0}!" +
")", "John Doe");
However, when I use a PSCustomObject and add it to the Message field, the Message field in the HTTP response payload is empty.
What can I do to ensure that the Message field is populated appropriately.
Note – everything works as expected when I use Azure CLI and I invoke RunPowershellScript command as an HTTP Request.