Hyper-V
Printed from:
Microsoft Hyper-V Comprehensive Cheatsheet
1. Installation and Role Configuration
Windows Server (2019 / 2022 / 2025)
123456# Install Hyper-V Role via PowerShell Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart # Verify installation Get-WindowsFeature *Hyper-V*
Windows 10/11 Pro, Enterprise, Education
- Settings > Apps > Optional features > More Windows features
- Check "Hyper-V" checkbox
- Restart computer
123# Alternative client install via DISM Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Note: The free standalone "Hyper-V Server" SKU was discontinued after the 2019 release. Use Windows Server (including the free evaluation) or Azure Local (formerly Azure Stack HCI) for bare-metal virtualization hosts.
2. Hyper-V Manager Interface
Key Navigation
- Server Manager > Tools > Hyper-V Manager
- Right-click local/remote server to manage
- Actions panel for core operations
- Virtual Machines view shows current state
For large-scale or cluster management, prefer Windows Admin Center (browser-based) or System Center Virtual Machine Manager (SCVMM) over the legacy Hyper-V Manager MMC.
3. Virtual Machine Creation and Configuration
GUI Method
- Open Hyper-V Manager or Windows Admin Center
- Actions > New > Virtual Machine
- Configuration steps:
- Name and location
- Generation selection (Gen 1 or Gen 2 — prefer Gen 2)
- Memory configuration
- Network connection
- Virtual hard disk setup
- OS installation method
PowerShell VM Creation
123456789# Create new VM New-VM -Name "ServerName" -MemoryStartupBytes 4GB -Generation 2 ` -NewVHDPath "C:\VMs\ServerName.vhdx" -NewVHDSizeBytes 80GB ` -SwitchName "ExternalSwitch" # Configure VM settings Set-VM -Name "ServerName" -ProcessorCount 4 -AutomaticCheckpointsEnabled $false Set-VMMemory -VMName "ServerName" -DynamicMemoryEnabled $true
Tip: Automatic checkpoints are enabled by default on client Hyper-V. Disable them for server workloads.
4. Virtual Hard Disk Management
VHD/VHDX Operations
123456789101112# Create new VHDX (dynamically expanding) New-VHD -Path C:\VMs\disk1.vhdx -SizeBytes 100GB -Dynamic # Create a fixed-size VHDX (best performance) New-VHD -Path C:\VMs\disk-fixed.vhdx -SizeBytes 100GB -Fixed # Attach disk to VM Add-VMHardDiskDrive -VMName "ServerName" -Path C:\VMs\disk1.vhdx # Inspect VHD details Get-VHD -Path C:\VMs\disk1.vhdx
Use VHDX for all new VMs (supports up to 64 TB, resilient to power loss). The older VHD format is limited to 2 TB and retained only for compatibility. VHD Set (.vhds) files enable guest clustering with shared virtual disks.
5. Virtual Networking
Virtual Switch Types
- External: Direct physical network connection
- Internal: Communication between VMs and host
- Private: VM-to-VM communication only
123456789101112# Create external virtual switch New-VMSwitch -Name "ExternalSwitch" -NetAdapterName "Ethernet" -AllowManagementOS $true # Create a SET (Switch Embedded Teaming) switch — preferred over legacy LBFO teams New-VMSwitch -Name "SETSwitch" -NetAdapterName "NIC1","NIC2" ` -EnableEmbeddedTeaming $true -AllowManagementOS $true # Configure NAT (useful for client/dev scenarios) New-VMSwitch -Name "NATSwitch" -SwitchType Internal New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NATSwitch)" New-NetNat -Name "InternalNAT" -InternalIPInterfaceAddressPrefix 192.168.0.0/24
LBFO NIC teaming is deprecated for use with the Hyper-V virtual switch. Use Switch Embedded Teaming (SET) for bandwidth aggregation and failover.
6. Checkpoints
123456789101112# Create checkpoint (production checkpoints are the default) Checkpoint-VM -Name "ServerName" # Switch a VM to standard (non-application-consistent) checkpoints Set-VM -Name "ServerName" -CheckpointType Standard # List checkpoints Get-VMCheckpoint -VMName "ServerName" # Restore to specific checkpoint Restore-VMCheckpoint -Name "CheckpointName" -VMName "ServerName" -Confirm:$false
*-VMSnapshotcmdlets still work as aliases, but*-VMCheckpointis the current naming. Production checkpoints use VSS inside the guest for application-consistent recovery.
7. Live Migration and Storage Migration
Prerequisites
- Same or compatible processor vendor across hosts
- Sufficient network bandwidth (10 GbE+ recommended; RDMA/SMB Direct for best throughput)
- Kerberos or CredSSP authentication; constrained delegation for Kerberos
- Shared storage for clustered live migration (CSV, SMB 3 file shares, S2D)
123456789101112# Enable live migration Enable-VMMigration Set-VMHost -VirtualMachineMigrationAuthenticationType Kerberos ` -VirtualMachineMigrationPerformanceOption SMB # Configure migration networks Add-VMMigrationNetwork -Subnet "192.168.1.0/24" # Shared-nothing live migration (no cluster required) Move-VM -Name "ServerName" -DestinationHost "Host02" ` -IncludeStorage -DestinationStoragePath "D:\VMs\ServerName"
8. Resource Allocation and Performance
VM Resource Configuration
12345678910111213# Set CPU priority and reserve Set-VMProcessor -VMName "ServerName" -Reserve 10 -RelativeWeight 200 # Memory management Set-VMMemory -VMName "ServerName" -DynamicMemoryEnabled $true ` -MinimumBytes 1GB -StartupBytes 2GB -MaximumBytes 8GB # Enable nested virtualization (required for WSL2 / containers / Hyper-V in a VM) Set-VMProcessor -VMName "ServerName" -ExposeVirtualizationExtensions $true # NUMA topology Set-VMProcessor -VMName "ServerName" -MaximumCountPerNumaNode 8
9. Integration Services
Management
123456# List integration services Get-VMIntegrationService -VMName "ServerName" # Enable/Disable specific service Enable-VMIntegrationService -Name "Guest Service Interface" -VMName "ServerName"
Integration components are now serviced through Windows Update inside the guest. The host-side ISO (
vmguest.iso) is no longer required for supported Windows and Linux guests.
10. Security Features
Secure Boot, vTPM, and Shielded / Trusted Launch VMs
12345678910# Enable Secure Boot for Generation 2 VMs Set-VMFirmware -VMName "ServerName" -EnableSecureBoot On # For Linux guests, use the MS UEFI CA template Set-VMFirmware -VMName "LinuxVM" -SecureBootTemplate MicrosoftUEFICertificateAuthority # Enable a virtual TPM (requires Host Guardian Service or local key protector) Set-VMKeyProtector -VMName "ServerName" -NewLocalKeyProtector Enable-VMTPM -VMName "ServerName"
Shielded VMs (host-attested, encrypted) remain available on Windows Server Datacenter but rely on the Host Guardian Service, which Microsoft no longer recommends for new deployments. On Azure Local, use Trusted Launch VMs with vTPM + Secure Boot for equivalent guest protection.
11. PowerShell Automation Cmdlets
Essential Cmdlets
New-VM,Remove-VMStart-VM,Stop-VM,Restart-VM,Suspend-VM,Resume-VMGet-VM,Set-VMMove-VM,Compare-VM,Import-VM,Export-VMCheckpoint-VM,Get-VMCheckpoint,Restore-VMCheckpoint,Remove-VMCheckpointGet-VMHost,Set-VMHost
All cmdlets live in the Hyper-V PowerShell module installed with RSAT-Hyper-V-Tools.
12. Failover Clustering and Azure Local
Configuration Steps
- Install Failover Clustering feature on each host
- Validate hardware (
Test-Cluster) and create the cluster (New-Cluster) - Add Hyper-V hosts and configure quorum (cloud witness recommended)
- Configure Cluster Shared Volumes (CSV) or SMB 3 / S2D storage
1234567# Install failover clustering Install-WindowsFeature Failover-Clustering -IncludeManagementTools # Validate and create a two-node cluster Test-Cluster -Node "Host01","Host02" New-Cluster -Name "HVCluster01" -Node "Host01","Host02" -StaticAddress 10.0.0.50
For hyperconverged clusters, Azure Local (the product formerly known as Azure Stack HCI / Azure Stack HCI OS 23H2) is the current Microsoft recommendation. It combines Hyper-V, Storage Spaces Direct, SDN, and Arc-based cloud management.
13. Backup and Disaster Recovery
Recommended Strategies
- Windows Server Backup or Azure Backup (host-level VM backup via VSS)
- Azure Site Recovery for cross-site/cloud DR replication
- Hyper-V Replica for asynchronous VM replication (built in, no extra license)
- System Center Data Protection Manager (DPM) or third-party tools (Veeam, Commvault, etc.)
- Use checkpoints only for short-lived test/dev rollback — not as a backup strategy
12345678910# Configure Hyper-V Replica on the primary Set-VMReplicationServer -ReplicationEnabled $true ` -AllowedAuthenticationType Kerberos ` -ReplicationAllowedFromAnyServer $true ` -DefaultStorageLocation "D:\Replicas" Enable-VMReplication -VMName "ServerName" -ReplicaServerName "DRHost" ` -ReplicaServerPort 80 -AuthenticationType Kerberos Start-VMInitialReplication -VMName "ServerName"
14. Troubleshooting and Monitoring
Common Diagnostic Commands
1234567891011# Check Hyper-V services Get-Service vmms, vmcompute # Event log analysis Get-WinEvent -LogName "Microsoft-Windows-Hyper-V-VMMS-Admin" Get-WinEvent -LogName "Microsoft-Windows-Hyper-V-Worker-Admin" # Per-VM resource metering Enable-VMResourceMetering -VMName "ServerName" Measure-VM -VMName "ServerName"
15. Best Practices
Performance and Reliability
- Use Generation 2 VMs with VHDX disks
- Enable dynamic memory for general workloads; use fixed memory for latency-sensitive ones
- Prefer fixed-size VHDX for IO-heavy production workloads
- Separate management, live migration, cluster, and tenant traffic (SET + QoS)
- Keep firmware, drivers, and Windows Updates current on hosts and guests
- Disable automatic checkpoints on server workloads
- Monitor resource utilization with Windows Admin Center, SCOM, or Azure Monitor
Security Recommendations
- Enable Secure Boot, vTPM, and (where supported) Trusted Launch on all Gen 2 VMs
- Keep Virtualization-Based Security (VBS) and HVCI enabled on hosts
- Implement network isolation with VLANs, SDN, or NAT switches
- Restrict Hyper-V admin rights; use JEA / RBAC where possible
- Encrypt VM storage (BitLocker on host volumes; vTPM-bound BitLocker in guests)
- For new hyperconverged deployments, consider Azure Local instead of building shielded-VM fabrics
Note: Always test configurations in staging before production deployment.
Continue Learning
Discover more cheatsheets to boost your productivity