Maintaining the health and performance of your virtual machines is crucial for optimizing your IT infrastructure. This PowerShell script automates the process of checking the status of Hyper-V virtual machines. It retrieves essential information about each VM, including its current state, uptime, and resource usage. This script will: 1. List all Hyper-V virtual machines. 2. Check the status of each VM (running, stopped, etc.). 3. Display information like uptime and resource consumption. Using this script can significantly enhance your ability to monitor and manage virtual machines efficiently.
# Import the Hyper-V module
Import-Module Hyper-V
# Get all virtual machines
$vms = Get-VM
# Output header
Write-Host "=== Hyper-V Virtual Machine Status ==="
# Loop through each VM and retrieve information
foreach ($vm in $vms) {
$status = $vm.State
$uptime = (Get-Date) - $vm.Uptime
$memoryAssigned = "{0:N2} GB" -f ($vm.MemoryAssigned / 1GB)
Write-Host "VM Name: $($vm.Name)"
Write-Host "Status: $status"
Write-Host "Uptime: $([math]::round($uptime.TotalHours, 2)) hours"
Write-Host "Assigned Memory: $memoryAssigned"
Write-Host "-------------------------------------"
}
Write-Host "VM status check completed."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-17Efficient Hyper-V VM Status Reporting Script
2025-01-10Hyper-V Virtual Machine Snapshot Management Script
2025-01-10Ready when you are.
Try ServerEngine free for 7 days.