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:
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:
- change the <YOUR HOST SERVERNAME> and <VM NAME YOU WANT TO CHECK> to whatever yours actually are
- 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:
2 – Commands To Determine HyperV Cluster Health
If you have a HyperV cluster the simple command to find out its status is
Get-ClusterNode -Cluster cluster1
Get-ClusterNode -Name node1 | Get-ClusterResource
For more details on cluster PowerShell commands see THIS Microsoft article.