在Azure中调用runco​​mmand时,使用Invoke-RestMethod的POST没有输出

时间:2018-09-12 10:10:57

标签: azure azure-runbook

我正在使用PowerShell使用Invoke-RESTMethod cmdlet针对Linux VM发出“ runco​​mmand”。

代码段如下。 它运行良好,并在我的Linux VM上触发了myscript.sh。 但是,脚本生成的输出未在PS控制台上显示。 我该怎么办才能将脚本输出到Powershell中,甚至可以通过POST请求来实现。

$ResourceGroupApiUri = "https://management.azure.com/subscriptions/xxxxxx-12cb-4d78-aa3c-ab1xxxxxxx3/resourceGroups/RG/providers/Microsoft.Compute/virtualMachines/Ubuntu/runCommand?api-version=2018-06-01"

$rb = @"
{
      'commandId': 'RunShellScript', 
      'script': [
          '/home/demouser/myscript.sh'
      ]
  }
"@
Invoke-RestMethod -Method POST -Body $rb -Uri $ResourceGroupApiUri -Headers $Headers -ContentType 'application/json' 

0 个答案:

没有答案