🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now β†’
Menu

Categories

Microsoft Hyper-V Complete Guide: PowerShell Management & Best Practices (2026)

Microsoft Hyper-V Complete Guide: PowerShell Management & Best Practices (2026)

Microsoft Hyper-V is a Type 1 hypervisor built into Windows Server and available as a free standalone product (Hyper-V Server). For organizations already invested in the Microsoft ecosystem, Hyper-V provides powerful virtualization with seamless Active Directory integration and PowerShell automation.

Microsoft Hyper-V virtualization platform

πŸ“₯ Free Hyper-V PowerShell Cheat Sheet

All essential Hyper-V PowerShell commands for VM management, networking, storage, and replication.

Download Free PDF β†’

Table of Contents

Hyper-V Overview

Hyper-V uses a microkernel architecture where the hypervisor runs directly on hardware, and even the host Windows installation runs as a privileged "parent partition" on top of the hypervisor. This means Hyper-V is technically a Type 1 hypervisor despite appearing to run "within" Windows.

Key Specifications (Windows Server 2025)

SpecificationMaximum
VMs per host1,024
vCPUs per VM240
RAM per host24 TB
RAM per VM12 TB
Virtual disk (VHDX)64 TB
Virtual switch portsUnlimited

Editions & Licensing

  • Windows Server Standard β€” Includes Hyper-V, 2 VM licenses per core license
  • Windows Server Datacenter β€” Includes Hyper-V, unlimited VMs per host
  • Hyper-V Server β€” Free standalone (discontinued after 2019, use Azure Stack HCI)
  • Windows 10/11 Pro/Enterprise β€” Client Hyper-V for development/testing

Installation

# Enable Hyper-V role on Windows Server
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart

# Enable on Windows 10/11
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

# Verify installation
Get-WindowsFeature Hyper-V

VM Management with PowerShell

# Create a new VM
New-VM -Name "WebServer" -MemoryStartupBytes 4GB -NewVHDPath "C:\VMs\WebServer.vhdx" -NewVHDSizeBytes 60GB -Generation 2

# Set VM properties
Set-VM -Name "WebServer" -ProcessorCount 4
Set-VMMemory -VMName "WebServer" -DynamicMemoryEnabled $true -MinimumBytes 2GB -MaximumBytes 8GB

# Add DVD drive with ISO
Add-VMDvdDrive -VMName "WebServer" -Path "C:\ISOs\ubuntu-22.04.iso"

# Power operations
Start-VM -Name "WebServer"
Stop-VM -Name "WebServer"              # Graceful shutdown
Stop-VM -Name "WebServer" -Force       # Force power off
Restart-VM -Name "WebServer"
Suspend-VM -Name "WebServer"           # Pause
Resume-VM -Name "WebServer"            # Resume

# List and monitor VMs
Get-VM
Get-VM | Select Name, State, CPUUsage, MemoryAssigned, Uptime
Get-VM | Where-Object { $_.State -eq 'Running' }

Virtual Networking

Hyper-V supports three types of virtual switches:

  • External β€” Connected to a physical NIC, provides network access
  • Internal β€” Communication between VMs and host, no physical network access
  • Private β€” Communication between VMs only, isolated from host
# Create virtual switches
New-VMSwitch -Name "External" -NetAdapterName "Ethernet" -AllowManagementOS $true
New-VMSwitch -Name "Internal" -SwitchType Internal
New-VMSwitch -Name "Private" -SwitchType Private

# Manage VM network adapters
Add-VMNetworkAdapter -VMName "WebServer" -SwitchName "External"
Get-VMNetworkAdapter -VMName "WebServer"
Set-VMNetworkAdapterVlan -VMName "WebServer" -Access -VlanId 100

# List switches
Get-VMSwitch | Select Name, SwitchType, NetAdapterInterfaceDescription

Storage & VHD Management

# Create virtual hard disks
New-VHD -Path "C:\VMs\data.vhdx" -SizeBytes 100GB -Dynamic
New-VHD -Path "C:\VMs\data.vhdx" -SizeBytes 100GB -Fixed

# Manage VHDs
Get-VHD -Path "C:\VMs\data.vhdx"
Resize-VHD -Path "C:\VMs\data.vhdx" -SizeBytes 200GB
Convert-VHD -Path "old.vhd" -DestinationPath "new.vhdx"
Optimize-VHD -Path "C:\VMs\data.vhdx" -Mode Full

# Attach/detach disks
Add-VMHardDiskDrive -VMName "WebServer" -Path "C:\VMs\data.vhdx"
Remove-VMHardDiskDrive -VMName "WebServer" -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 1

Checkpoints & Backup

# Checkpoints (snapshots)
Checkpoint-VM -Name "WebServer" -SnapshotName "Pre-Update"
Get-VMSnapshot -VMName "WebServer"
Restore-VMSnapshot -Name "Pre-Update" -VMName "WebServer" -Confirm:$false
Remove-VMSnapshot -VMName "WebServer" -Name "Pre-Update"

# Export/Import
Export-VM -Name "WebServer" -Path "D:\Exports"
Import-VM -Path "D:\Exports\WebServer\Virtual Machines\*.vmcx" -Copy

Replication & Live Migration

# Enable Hyper-V Replica
Enable-VMReplication -VMName "WebServer" -ReplicaServerName "Host2" -ReplicaServerPort 443 -AuthenticationType Certificate

# Start replication
Start-VMInitialReplication -VMName "WebServer"

# Check replication health
Get-VMReplication | Select VMName, State, Health, FrequencySec

# Live migration
Move-VM -Name "WebServer" -DestinationHost "Host2" -IncludeStorage -DestinationStoragePath "D:\VMs"

# Storage-only migration
Move-VMStorage -VMName "WebServer" -DestinationStoragePath "D:\NewStorage"

Best Practices

  1. Use Generation 2 VMs β€” Better performance, UEFI boot, Secure Boot support
  2. Enable Dynamic Memory β€” Allows Hyper-V to allocate RAM based on actual demand
  3. Use VHDX over VHD β€” VHDX supports up to 64 TB, better corruption recovery
  4. Install Integration Services β€” Enhances performance and management capabilities
  5. Separate management network β€” Use a dedicated NIC for Hyper-V management
  6. Regular checkpoints before updates β€” But don't rely on them for long-term backups
  7. Use Failover Clustering for HA β€” Automatic VM failover between cluster nodes
  8. Monitor with Windows Admin Center β€” Modern web-based management for Hyper-V

πŸ“₯ Download the Hyper-V Cheat Sheet

All essential PowerShell commands for Hyper-V in a printable PDF.

Download Free PDF β†’

Related Articles

Share this article:
Dargslan Editorial Team (Dargslan)
About the Author

Dargslan Editorial Team (Dargslan)

Collective of Software Developers, System Administrators, DevOps Engineers, and IT Authors

Dargslan is an independent technology publishing collective formed by experienced software developers, system administrators, and IT specialists.

The Dargslan editorial team works collaboratively to create practical, hands-on technology books focused on real-world use cases. Each publication is developed, reviewed, and...

Programming Languages Linux Administration Web Development Cybersecurity Networking

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.