← script library

Automate System Health Checks with PowerShell for Hyper-V

Hyper-VJanuary 4, 2025

Regularly monitoring the health of your Hyper-V virtual machines is crucial to ensure optimal performance and prevent downtime. This PowerShell script automates the process of checking the status of your Hyper-V VMs, gathering valuable insights like CPU usage, memory consumption, and the state of each VM. Follow these steps to implement a straightforward health check for your Hyper-V environment:

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

# Retrieve status of all Hyper-V virtual machines
$VMs = Get-VM | Select-Object Name, State, CPUUsage, MemoryAssigned, MemoryDemand

# Display the health check results
$VMs | Format-Table -AutoSize

# Export the results to a CSV file for tracking
$VMs | Export-Csv -Path "C:\VM_Health_Check_Results.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.