虚拟机状态的可能值

Possible values for state & status of Virtual machines

我们可以获取带有 powershell cmdlet 的虚拟机列表 "Get-VM"。返回的集合有两列 "State" 和 "Status"。我需要知道 VM 的可能状态是什么。我有一个应用程序需要根据 VM 的状态(特别是错误状态)执行各种操作。

你可以使用powershell命令:

Import-Module Hyper-V

[enum]::GetNames([Microsoft.HyperV.Powershell.VMState])
[enum]::GetNames([Microsoft.HyperV.Powershell.VMOperationalStatus])