← script library

Automate System Health Checks for Hyper-V with PowerShell

Hyper-VJanuary 4, 2025

Ensuring the health of your Hyper-V environment is crucial for maintaining performance and availability. Regular health checks can help you proactively identify issues before they escalate. This PowerShell script automates the process of checking the status of your Hyper-V virtual machines, monitoring their resource usage, and generating a health report.

powershell
# Import the Hyper-V module
Import-Module Hyper-V

# Retrieve and select important properties of virtual machines
$vms = Get-VM | Select-Object Name, State, CPUUsage, MemoryAssigned, MemoryDemand

# Display VM health check results in a table format
$vms | Format-Table -AutoSize

# Export VM health check results to a CSV file
$vms | Export-Csv -Path "C:\HyperV_VM_Health_Check_Report.csv" -NoTypeInformation

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.