Get started Bring yourself up to speed with our introductory content.

Perform a Hyper-V health check with these PowerShell commands

Get reports on the general health status of Hyper-V hosts and VMs running on Hyper-V hosts, as well as information on installed roles and features with PowerShell commands.

Every administrator who has worked with Windows Server 2008 and later OSes knows the value of PowerShell scripting....

Microsoft is making sure PowerShell becomes the primary scripting language to interact with Windows Server roles, features, Office 365 and Azure clouds. However, not many Hyper-V administrators know that PowerShell can be used to create procedures to perform a complete Hyper-V health check on hosts and the VMs running on them.

When checking Hyper-V host and VM health, you want to look at least a few basic items, listed below:

  • General health status of Hyper-V hosts
  • General health status of VMs
  • Installed roles and features on Hyper-V hosts

Let's take a look at each of the health check items and the necessary PowerShell scripts or commands that you would want to use to get the required data.

General health status of Hyper-V hosts

When it comes to performing a general Hyper-V health check of the hosts, it's important that you check the Hyper-V OS, the Hyper-V OS service pack, memory usages, CPU usages, Hyper-V uptime, total memory, used memory and available memory. There are many PowerShell cmdlets that will provide you with the necessary information, but be sure that the commands you put together are able to collect information from all of your Hyper-V hosts. For stand-alone Hyper-V hosts, you can execute individual PowerShell cmdlets, but to collect information from a Hyper-V cluster, the Get-ClusterNode PowerShell cmdlet is required. Here is an example:

Once you've finished executing the PowerShell script shown above, it will generate a report (Figure A).

Host health check report
Figure A. Hyper-V host basic health check report

General health status of VMs

When performing a Hyper-V health check of VMs running on the hosts, make sure to check the state of the VM, the integration services version, VM uptime, if the VM is clustered or not, virtual processors and memory configured on the VMs as well as VM dynamic memory status. Most of the VM information can be collected using the Get-VM PowerShell cmdlet. The PowerShell script shown below uses this command to collect health check information from VMs configured in a Hyper-V cluster.

This script will generate a CSV report under C:\Temp folder. The report will include VM name, VM current state, VM uptime, VM integration services version and VM overall status (Figure B).

VM health check report
Figure B. General health check report of VMs from each Hyper-V host

Installed roles and features on Hyper-V hosts

It's important that Hyper-V hosts run only the required roles, in order to avoid memory and CPU consumption by other roles and features. The required roles for a Hyper-V host are the Hyper-V Server role and Failover Clustering feature. To get installed roles and features on Hyper-V hosts, run the Get-WindowsFeature PowerShell command as shown below:

The PowerShell scripts featured in this article can be used for a Hyper-V cluster. While there are other health check tasks you might want to perform based on your requirements, such as checking Hyper-V Replica, the basic things to include in a Hyper-V health check procedure have been highlighted above.

Next Steps

Learn about improvements to Windows Server 2016 Hyper-V Manager

Upgrade Hyper-V VM configuration version in just two steps

Manage VMs with these Windows Server 2016 Hyper-V features

This was last published in February 2017

Dig Deeper on Microsoft Hyper-V management

PRO+

Content

Find more PRO+ content and other member only offers, here.

Join the conversation

4 comments

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

What are some other tasks you should perform when doing a Hyper-V health check?
Cancel
Unitrends uses Hyper-V for backup and disaster recovery solutions for up to minute RPOs using In cremental Forever Scheduling. 
Cancel
It would be great to schedule and send the reports by mail.
Cancel
Great information! I've not used Hyper-V much but love PowerShell and know anyone who does and didn't know about these commands and necessary checks is glad you put this info out there. Thanks!
Cancel

-ADS BY GOOGLE

SearchVMware

SearchWindowsServer

SearchCloudComputing

SearchVirtualDesktop

SearchDataCenter

Close