Windows PowerShell Hyper-V module cmdlets: VM management, checkpoints, virtual switches, VHD/VHDX and live migration. Searchable and copy-ready.
advertisement
Run in an elevated PowerShell session on the Hyper-V host, or add -ComputerName HV01 for remote management. Enable WinRM first: Enable-PSRemoting -Force
Get-VM -ComputerName HV01List VMs on a remote Hyper-V host
Get-VM | Where-Object {$_.State -eq 'Off'}Find all stopped VMs
(Get-VM).CountTotal VM count on this host
Get-VM | Group-Object State | Select Name, CountVM count by power state
β‘ Power Operations
Start-VM -Name "MyVM"Power on VM
Stop-VM -Name "MyVM"Guest OS shutdown (requires Integration Services)
Stop-VM -Name "MyVM" -TurnOffHard power off (like pulling the plug)
Restart-VM -Name "MyVM" -ForceHard reset VM
Suspend-VM -Name "MyVM"Save state (hibernate) VM to disk
Resume-VM -Name "MyVM"Resume VM from saved state
Get-VM | Start-VMStart ALL VMs on this host
π Create & Configure
New-VM -Name "NewVM" -Generation 2 -MemoryStartupBytes 4GB -SwitchName "Default Switch" -NewVHDPath "C:\VMs\NewVM.vhdx" -NewVHDSizeBytes 60GBCreate a Gen 2 VM with a new VHDX
Generation 2 VMs use UEFI firmware, support Secure Boot and PXE boot from virtual NICs, and generally perform better. Use Gen 2 for all new Windows Server 2012+ and modern Linux guests. You cannot change generation after VM creation, choose wisely upfront. Note that some older OSes (Windows XP, Server 2003, FreeBSD) require Gen 1.
Checkpoints vs Export for backup
Checkpoints are not backups; they consume additional disk space and degrade I/O performance as they grow. The safe approach: create a checkpoint before patching, verify the system works, then delete the checkpoint to merge it back. For actual backups use Export-VM to a separate drive, or a dedicated solution like Veeam, Altaro or Windows Server Backup.
Remote management
Add -ComputerName HV02 to most cmdlets for remote management. Ensure WinRM is enabled (Enable-PSRemoting -Force) and the account has Hyper-V Administrator rights. For non-domain environments, add the remote host to TrustedHosts: Set-Item WSMan:\localhost\Client\TrustedHosts -Value "HV02".