Starts one VM by name and polls its state for up to a minute, so the script only reports success when the VM is genuinely running. A VM that is already running is left alone. Waiting for the state matters when this is one step of a runbook that brings an environment up in order.
powershell
# Hyper-V Power ON VM
# Single use case: start one VM and wait until it is running
#-----------------------------------------------------------------
function Write-Log {
param($Message)
Write-Host "<WRITE-LOG = `"*$Message*`">"
}
# --- Parameters (replace via ServerEngine API parameters if needed) ---
$VMName = "MyVM"
if (-not (Get-Module -ListAvailable -Name Hyper-V)) {
Write-Log "Hyper-V module not available - is the Hyper-V role installed on this host?"
return
}
$vm = Get-VM -Name $VMName -ErrorAction SilentlyContinue
if ($null -eq $vm) { Write-Log "VM not found: $VMName"; return }
if ($vm.State -eq "Running") {
Write-Log "VM $VMName is already running - nothing to do."
return
}
Write-Log "Starting VM $VMName (current state: $($vm.State))..."
Start-VM -Name $VMName -ErrorAction SilentlyContinue
$timeout = 60
while ($timeout -gt 0) {
Start-Sleep 5
$timeout -= 5
$vm = Get-VM -Name $VMName
if ($vm.State -eq "Running") { break }
}
if ($vm.State -eq "Running") {
Write-Log "VM $VMName is running."
} else {
Write-Log "WARNING: VM $VMName is in state $($vm.State) after start attempt!"
}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-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-10Automated Virtual Machine Restart with PowerShell and Hyper-V
2025-01-10Ready when you are.
Try ServerEngine free for 7 days.