Monitoring the status of Hyper-V virtual machines is essential for administrators to maintain optimal performance and uptime. In this post, we will share a PowerShell script that retrieves and displays the current state of all Hyper-V virtual machines. This script will help you quickly identify which VMs are running, stopped, or in any other state, enabling effective management of your virtualization environment.
powershell
$VMs = Get-VM
$VMStatusList = @()
foreach ($VM in $VMs) {
$VMStatusList += [PSCustomObject]@{
Name = $VM.Name
Status = $VM.State
}
}
$VMStatusList
$VMStatusList | Format-Table -AutoSize
Write-Host "Virtual Machine statuses retrieved successfully."
try {
$VMs = Get-VM
if ($null -eq $VMs) {
throw 'No virtual machines found.'
}
} catch {
Write-Host 'ERROR: Unable to retrieve VM status. Details: ' $_.Exception.Message
}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.
More in Hyper-V
Create a Hyper-V Checkpoint with PowerShell
2026-08-17Delete Old Hyper-V Checkpoints with PowerShell
2026-08-17Start a Hyper-V VM with PowerShell
2026-08-17Shut Down a Hyper-V VM with PowerShell
2026-08-17Hyper-V Virtual Machine Snapshot Management Script
2025-01-10Automated Virtual Machine Restart with PowerShell and Hyper-V
2025-01-10Ready when you are.
Try ServerEngine free for 7 days.