Categories: Windows Server

SOLVED: Easily Determine The Health Status of a HyperV Virtual Machine

If you work with HyperV there will come a time when you need to run some basic PowerShell commands to find out how health your HyperV Virtual Machines really are.

1 – Commands To Determine HyperV Health

Easy command to check all of the HyperV VMs at once:

In a POWERSHELL as an ADMINISTRATOR use:

get-vm

Note this command does not work in a CMD window… it must be POWERSHELL

Easy command for Full Details on a Specific HyperV VM:

If you want detailed report on a specific virtual machine, this command will provide you with the operational status and status which generally can be inferred as the VM’s health.

There are two things to note before you run this command:

  1. change the <YOUR HOST SERVERNAME> and <VM NAME YOU WANT TO CHECK> to whatever yours actually are
  2. This command will work on Windows Server 2012 R2, 2016, 2019, 2022 and Azure.  If you are working on Server 2012 R1 or Server 2008 remove the “v2” ie “Get-WmiObject -Namespace root\virtualization -Compu...

Get-WmiObject -Namespace root\virtualization\v2 -ComputerName "<your host server name>" -Query "Select * From Msvm_ComputerSystem Where ElementName='<vm name you want to check>'"

The HyperV Operational Status codes are as follows:

0: Ok
1: Degraded
2: PredictiveFailure
3: InService
4: Dormant
5: SupportingEntityInError
6: ApplyingSnapshot
7: CreatingSnapshot
8: DeletingSnapshot
9: WaitingToStart
10: MergingDisks
11: ExportingVirtualMachine
12: MigratingVirtualMachine
13: BackingUpVirtualMachine
14: ModifyingUpVirtualMachine
15: StorageMigrationPhaseOne
16: StorageMigrationPhaseTwo
17: MigratingPlannedVm
18: CheckingCompatibility
19: ApplicationCriticalState
20: CommunicationTimedOut
21: CommunicationFailed
22: NoIommu
23: NoIovSupportInNic
24: SwitchNotInIovMode
25: IovBlockedByPolicy
26: IovNoAvailResources
27: IovGuestDriversNeeded
28: CriticalIoError

 

2 – Commands To Determine HyperV Cluster Health

If you have a HyperV cluster the simple command to find out its status is

Get-ClusterNode

Get-ClusterNode -Cluster cluster1

Get-ClusterNode -Name node1 | Get-ClusterResource

For more details on cluster PowerShell commands see THIS Microsoft article.

Published by
Ian Matthews

This website uses cookies.