【问题标题】:Having problem with Powershell script for VM Agent Status and WindowsAzureGuestAgent serviceVM 代理状态和 WindowsAzureGuestAgent 服务的 Powershell 脚本有问题
【发布时间】:2019-11-07 05:50:21
【问题描述】:

我当前的代码:

if ($VM.VMAgent.Statuses[0].DisplayStatus -eq "Not Ready") {
    Write-Host $VM.VMAgent.Statuses.Message
} else {
    Start-Service $AzureAgentServiceName
}

场景:
1. 检查VM Agent状态GoodNot Good,如果VM Agent状态GOOD不需要启动WindowsAzureGuestAgent服务。
2.如果VM Agent状态NOT GOOD需要启动WindowsAzureGuestAgent服务。

我的脚本中现在存在问题: 我无法检查代理状态是好还是不好执行。谁能帮我写代码?

【问题讨论】:

    标签: azure powershell virtual-machine


    【解决方案1】:

    你的逻辑有点问题。

    您可以检查代理是否准备好,但如果代理服务未运行,则无法启动代理服务。任何部署后的操作系统更改都需要该代理,包括从外部 VM 启动服务。

    此外,如果 VM 未运行或未安装代理,您将无法获得 VMAgent 状态。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-24
      • 1970-01-01
      • 2019-08-22
      • 1970-01-01
      • 1970-01-01
      • 2016-06-11
      • 2016-08-04
      • 2021-12-17
      相关资源
      最近更新 更多