Hyper-V Virtualization Guide — VM Creation, Networking, and Snapshots

What Is Hyper-V?

Hyper-V is a Type 1 hypervisor built into Windows. Unlike VirtualBox or VMware, it runs directly on hardware, providing superior performance. It is available on Windows 10/11 Pro, Enterprise, and Education editions. WSL2 and Docker Desktop also use Hyper-V technology internally.

This article covers Hyper-V activation, VM creation, virtual network configuration, and checkpoint (snapshot) management.

Activating Hyper-V

CPU virtualization (Intel VT-x or AMD-V) must be enabled in BIOS to use Hyper-V.

# Check virtualization support
systeminfo | Select-String "Hyper-V"
# Sample output:
# Hyper-V Requirements: VM Monitor Mode Extensions: Yes
#                       Virtualization Enabled In Firmware: Yes
#                       Second Level Address Translation: Yes

# Enable Hyper-V (requires admin privileges, reboot needed)
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

# Or enable via DISM
dism /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V

# Verify activation
Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
# Sample output:
# FeatureName : Microsoft-Hyper-V
# State       : Enabled

Creating a VM (PowerShell)

Creating VMs via PowerShell instead of the Hyper-V Manager GUI enables automation.

# Set VM storage paths
$vmPath = "D:\HyperV\VMs"
$vhdPath = "D:\HyperV\VHDs"
New-Item -ItemType Directory -Force -Path $vmPath, $vhdPath

# Create VM (Ubuntu Server example)
$vmName = "Ubuntu-Server"

New-VM -Name $vmName `
    -MemoryStartupBytes 4GB `
    -Generation 2 `
    -NewVHDPath "$vhdPath\$vmName.vhdx" `
    -NewVHDSizeBytes 50GB `
    -Path $vmPath `
    -SwitchName "Default Switch"

# Modify VM settings
Set-VM -Name $vmName `
    -ProcessorCount 4 `
    -DynamicMemory `
    -MemoryMinimumBytes 2GB `
    -MemoryMaximumBytes 8GB `
    -AutomaticStartAction Nothing `
    -AutomaticStopAction ShutDown

# Configure Secure Boot (use Linux template)
Set-VMFirmware -VMName $vmName `
    -SecureBootTemplate "MicrosoftUEFICertificateAuthority"

# Attach ISO image (for installation)
Add-VMDvdDrive -VMName $vmName `
    -Path "D:\ISOs\ubuntu-24.04-live-server-amd64.iso"

# Change boot order (DVD first)
$dvd = Get-VMDvdDrive -VMName $vmName
Set-VMFirmware -VMName $vmName -FirstBootDevice $dvd

# Start VM
Start-VM -Name $vmName

# Check VM status
Get-VM -Name $vmName | Format-Table Name, State, CPUUsage, MemoryAssigned
# Sample output:
# Name           State   CPUUsage MemoryAssigned
# Ubuntu-Server  Running 12       4294967296

Basic VM Management

Basic management commands for starting, stopping, and deleting VMs.

# List all VMs
Get-VM | Format-Table Name, State, CPUUsage, MemoryAssigned, Uptime

# Start/shutdown/force stop VM
Start-VM -Name "Ubuntu-Server"
Stop-VM -Name "Ubuntu-Server"           # Graceful shutdown (sends shutdown signal to guest OS)
Stop-VM -Name "Ubuntu-Server" -Force    # Force stop (power off)

# Pause/resume VM
Suspend-VM -Name "Ubuntu-Server"
Resume-VM -Name "Ubuntu-Server"

# Connect to VM console
vmconnect.exe localhost "Ubuntu-Server"

# Delete VM (VHD files must be deleted manually)
Stop-VM -Name "Ubuntu-Server" -Force
Remove-VM -Name "Ubuntu-Server" -Force
Remove-Item "D:\HyperV\VHDs\Ubuntu-Server.vhdx"

Virtual Network Configuration

Hyper-V virtual switches come in three types.

TypeDescriptionInternet AccessHost Access
ExternalConnected to physical NICYesYes
InternalHost-VM communicationNoYes
PrivateVM-to-VM communication onlyNoNo
# Check existing virtual switches
Get-VMSwitch | Format-Table Name, SwitchType, NetAdapterInterfaceDescription

# Create External switch (internet + host access)
New-VMSwitch -Name "ExternalSwitch" `
    -NetAdapterName "Ethernet" `
    -AllowManagementOS $true
# -AllowManagementOS $true: host also uses the same network

# Create Internal switch (host-VM private network)
New-VMSwitch -Name "DevNetwork" -SwitchType Internal

# Assign IP to Internal switch (host side)
$adapter = Get-NetAdapter | Where-Object { $_.Name -like "*DevNetwork*" }
New-NetIPAddress -InterfaceIndex $adapter.ifIndex `
    -IPAddress 192.168.10.1 `
    -PrefixLength 24

# Configure NAT (enable internet access via Internal switch)
New-NetNat -Name "DevNAT" `
    -InternalIPInterfaceAddressPrefix 192.168.10.0/24

# Connect network adapter to VM
Connect-VMNetworkAdapter -VMName "Ubuntu-Server" -SwitchName "ExternalSwitch"

# Delete virtual switch
Remove-VMSwitch -Name "DevNetwork" -Force

Checkpoint (Snapshot) Management

Checkpoints save the state of a VM at a specific point in time. Creating a checkpoint before configuration changes or testing lets you revert at any time.

# Create checkpoint
Checkpoint-VM -Name "Ubuntu-Server" -SnapshotName "Post-installation state"

# List checkpoints
Get-VMCheckpoint -VMName "Ubuntu-Server" | Format-Table Name, CreationTime, ParentCheckpointName
# Sample output:
# Name                    CreationTime          ParentCheckpointName
# Post-installation state 2026-03-09 10:30:00

# Create additional checkpoint
Checkpoint-VM -Name "Ubuntu-Server" -SnapshotName "After Docker install"

# Restore to checkpoint
Restore-VMCheckpoint -VMName "Ubuntu-Server" -Name "Post-installation state" -Confirm:$false
# VM reverts to that point in time

# Delete checkpoint (reclaim disk space)
Remove-VMCheckpoint -VMName "Ubuntu-Server" -Name "After Docker install"

# Delete all checkpoints
Get-VMCheckpoint -VMName "Ubuntu-Server" | Remove-VMCheckpoint

Checkpoint Type Settings

Hyper-V supports two checkpoint types.

# Standard checkpoint: includes VM state + memory (fast but large)
Set-VM -Name "Ubuntu-Server" -CheckpointType Standard

# Production checkpoint: uses guest OS backup technology (stable, recommended for production)
Set-VM -Name "Ubuntu-Server" -CheckpointType Production

# Disable automatic checkpoints (prevent auto-creation on VM start)
Set-VM -Name "Ubuntu-Server" -AutomaticCheckpointsEnabled $false

VM Cloning and Export

Used for moving VMs to another host or backing up.

# Export VM (full backup)
Export-VM -Name "Ubuntu-Server" -Path "D:\Backup\HyperV"
# Includes VM settings, VHD, and checkpoints

# Import VM
$importPath = "D:\Backup\HyperV\Ubuntu-Server"
$report = Compare-VM -Path "$importPath\Virtual Machines\*.vmcx"
Import-VM -CompatibilityReport $report

# Quick VM clone by copying VHD
Copy-Item "D:\HyperV\VHDs\Ubuntu-Server.vhdx" `
    -Destination "D:\HyperV\VHDs\Ubuntu-Server-Clone.vhdx"

New-VM -Name "Ubuntu-Clone" `
    -MemoryStartupBytes 4GB `
    -Generation 2 `
    -VHDPath "D:\HyperV\VHDs\Ubuntu-Server-Clone.vhdx" `
    -SwitchName "Default Switch"

Practical Tips

  • Use Generation 2: Modern Linux/Windows versions need Generation 2 VMs for UEFI boot, Secure Boot, and VHDX support
  • Dynamic memory: When running multiple VMs simultaneously, dynamic memory efficiently distributes resources
  • Clean up checkpoints: Checkpoints consume significant disk space, so regularly delete unnecessary ones
  • Default Switch: The simplest network setup. Provides internet access via NAT with no additional configuration needed
  • Enhanced Session: Enable Enhanced Session mode on Linux VMs for clipboard sharing and resolution adjustment
  • Auto-start: For server VMs, use Set-VM -AutomaticStartAction Start to auto-start on Windows boot
  • Coexistence with WSL2: Enabling Hyper-V may conflict with other hypervisors like VirtualBox, so be aware

Was this article helpful?