Module 04: Hyper-V Virtualization

Master Windows Server virtualization with Hyper-V.

Learning Objectives

  • Understand Type 1 vs Type 2 hypervisors
  • Create and configure virtual machines
  • Manage virtual switches and networking
  • Use checkpoints for point-in-time recovery
  • Administer Hyper-V with GUI and PowerShell

AZ-800 Alignment

Domain: Manage virtual machines and containers (15-20%)

This module covers Hyper-V architecture, VM creation, virtual networking, and checkpoints.

Hyper-V: one host, many isolated VMs Physical hardware: CPU, RAM, NIC, disk single physical server Hyper-V hypervisor DC01 VMWindowsServer 20224 vCPU, 8 GBRunning Web01 VMUbuntu 22LAMP stack2 vCPU, 4 GBRunning SQL01 VMWindowsServer Core8 vCPU, 32 GBRunning Test VMSnapshotrestore pointisolatedStopped

Hypervisor Types

Type 1 (Bare-Metal)

  • Runs directly on hardware
  • No host OS required
  • Better performance
  • Examples: Hyper-V, VMware ESXi
┌─────────────────────┐ │ Virtual Machines │ ├─────────────────────┤ │ HYPERVISOR │ ├─────────────────────┤ │ HARDWARE │ └─────────────────────┘

Type 2 (Hosted)

  • Runs on top of host OS
  • Easier to install
  • Additional overhead
  • Examples: VirtualBox, VMware Workstation
┌─────────────────────┐ │ Virtual Machines │ ├─────────────────────┤ │ HYPERVISOR │ ├─────────────────────┤ │ HOST OS │ ├─────────────────────┤ │ HARDWARE │ └─────────────────────┘

Hyper-V Is Type 1

When you enable Hyper-V on Windows, the entire OS becomes a virtual machine running on the hypervisor!

Type 1 (bare metal) vs Type 2 (hosted) Type 1: bare-metal Hyper-V, ESXi, KVM, Xen VM 1 VM 2 VM 3 Hypervisor Hardware ⚡ Best performance 🛡️ Smallest attack surface For: production servers Type 2: hosted VirtualBox, VMware Workstation, Parallels VM 1 VM 2 VM 3 Hypervisor app Host OS (Windows, macOS) Hardware 🐢 Slower (extra layer) For: dev, testing, sandboxes

VM Generations

Feature Generation 1 Generation 2
FirmwareBIOS (Legacy)UEFI
Boot DiskIDE controllerSCSI controller
Secure BootNoYes
PXE BootLegacy adapter onlyStandard adapter
DVD BootIDE CD-ROMSCSI
Hot Add MemoryNoYes
Guest OSOlder Windows, LinuxWindows 8+, Modern Linux

When to Use Generation 1

Only use Gen 1 when running legacy operating systems (Windows 7, Server 2008) or older 32-bit Linux distributions.

VM Generation: pick at creation, irrevocable Generation 1 legacy BIOS + IDE ✓ All Windows/Linux guests ✓ 32-bit OS support ✓ PXE boot from legacy NIC ✗ 2 TB boot disk limit ✗ No Secure Boot ✗ No GPU partitioning Best for: old / 32-bit guests PXE-deployed VMs Generation 2 UEFI + SCSI + Secure Boot ✓ Larger boot disks (>2 TB) ✓ Secure Boot enabled ✓ Faster boot times ✓ Hot-add/remove SCSI disks ✓ Network PXE via virtual NIC ✗ 64-bit guests only Best for: modern Windows Server + modern Linux distros

Virtual Switches

Switch Types

Type VMs ↔ VMs VMs ↔ Host VMs ↔ Network
External
Internal
Private

Create an External switch to give VMs access to the physical network through a host NIC.

# Bind a virtual switch to the physical Ethernet adapter PS C:\> New-VMSwitch -Name "External" -NetAdapterName "Ethernet" -AllowManagementOS $true
# Expected output: # ───────────────────────────────────────── Name SwitchType NetAdapterInterfaceDescription ──── ────────── ────────────────────────────── External External Intel(R) Ethernet Connection

An Internal switch lets VMs communicate with the host, but not with the physical network.

# Create a switch for host-to-VM communication only PS C:\> New-VMSwitch -Name "Internal" -SwitchType Internal

A Private switch isolates VMs from both the host and the physical network entirely.

# Create an isolated switch for VM-to-VM traffic only PS C:\> New-VMSwitch -Name "Private" -SwitchType Private
Virtual switch decides what VMs can reach External bound to physical NIC VM VM vSwitch Physical NIC corporate LAN VMs ↔ network production use Internal host + VMs only VM VM vSwitch Host (no NIC) no LAN access host + VMs only test labs Private VMs only, no host VM VM vSwitch isolated fully isolated VM ↔ VM only malware sandbox

Checkpoints (Snapshots)

Checkpoints capture VM state for point-in-time recovery.

Checkpoint Types

Standard Checkpoint

  • Captures memory + disk state
  • Complete VM state preserved
  • Larger file size
  • Recommended for dev/test

Production Checkpoint

  • Uses VSS (backup technology)
  • Application-consistent
  • Supported in production
  • Default in Windows Server

Capture the current VM state before making changes so you can roll back if needed.

# Save a named checkpoint before applying updates PS C:\> Checkpoint-VM -Name "DC02" -SnapshotName "Before Updates"

List all checkpoints for a VM to see your available restore points.

# View all checkpoints for a specific VM PS C:\> Get-VMCheckpoint -VMName "DC02"
# Expected output: # ───────────────────────────────────────── VMName Name SnapshotType CreationTime ────── ──── ──────────── ──────────── DC02 Before Updates Production 2/8/2026 10:30:00 AM DC02 Post-Config Production 2/7/2026 3:15:00 PM

Roll back to a previous checkpoint to undo changes that caused problems.

# Restore the VM to the "Before Updates" checkpoint PS C:\> Restore-VMCheckpoint -Name "Before Updates" -VMName "DC02"
Checkpoint: a point-in-time VM state you can revert to SQL01 (current)live VM Before patchMar 12, 14:30 Branch: dev testMar 13, 09:15 After patch v1Mar 13, 11:00 After patch v2Mar 14, 09:30 ⚠ Production caveat Checkpoints are growing diff disks Long-lived = slow VM

PowerShell VM Management

Essential Cmdlets

Get a quick overview of every VM on this Hyper-V host and their current state.

# List all virtual machines on this host PS C:\> Get-VM
# Expected output: # ───────────────────────────────────────── Name State CPUUsage MemoryAssigned Uptime Status ──── ───── ──────── ────────────── ────── ────── DC01 Running 2 4096 MB 3.12:45:00 Operating normally DC02 Running 1 4096 MB 3.12:44:00 Operating normally WebServer Off 0 0 MB 00:00:00 Operating normally

Create a new Generation 2 VM with a dynamically expanding virtual hard disk.

# Create a Gen 2 VM with 4GB RAM and a 100GB VHDX PS C:\> New-VM -Name "WebServer" -Generation 2 -MemoryStartupBytes 4GB ` -NewVHDPath "C:\VMs\WebServer.vhdx" -NewVHDSizeBytes 100GB
Hyper-V PowerShell: create, start, snapshot Hyper-V module, on the host PS> New-VM -Name "SQL02" -MemoryStartupBytes 8GB -Generation 2 -SwitchName "vSwitch-Ext" PS> Set-VMProcessor SQL02 -Count 4 -Reserve 50 PS> Add-VMHardDiskDrive SQL02 -Path D:\VHDs\sql02-data.vhdx PS> Start-VM SQL02 PS> Checkpoint-VM SQL02 -SnapshotName "pre-patch" PS> Get-VM | Where State -eq Running | Format-Table Name, State, CPUUsage, MemoryAssigned

PowerShell VM Management (cont.)

Start a VM to boot it, or stop it gracefully. Use -Force for an immediate power-off.

# Boot the VM (graceful start) PS C:\> Start-VM -Name "WebServer"
# Shut down the VM gracefully through the guest OS PS C:\> Stop-VM -Name "WebServer"
# Force power-off immediately (like pulling the plug) PS C:\> Stop-VM -Name "WebServer" -Force

Adjust CPU and memory settings on a VM without recreating it.

# Assign 4 vCPUs and enable dynamic memory PS C:\> Set-VM -Name "WebServer" -ProcessorCount 4 -DynamicMemory

Attach a VM's network adapter to a virtual switch for network connectivity.

# Connect the VM to the External virtual switch PS C:\> Connect-VMNetworkAdapter -VMName "WebServer" -SwitchName "External"
Hyper-V PowerShell: create, start, snapshot Hyper-V module, on the host PS> New-VM -Name "SQL02" -MemoryStartupBytes 8GB -Generation 2 -SwitchName "vSwitch-Ext" PS> Set-VMProcessor SQL02 -Count 4 -Reserve 50 PS> Add-VMHardDiskDrive SQL02 -Path D:\VHDs\sql02-data.vhdx PS> Start-VM SQL02 PS> Checkpoint-VM SQL02 -SnapshotName "pre-patch" PS> Get-VM | Where State -eq Running | Format-Table Name, State, CPUUsage, MemoryAssigned

Module Summary

Key Takeaways

  • Type 1 Hypervisor - Hyper-V runs directly on hardware
  • Generation 2 - Use for modern Windows/Linux (UEFI, Secure Boot)
  • Virtual Switches - External (network), Internal (host+VMs), Private (VMs only)
  • Checkpoints - Production (VSS-based) or Standard (memory+disk)
  • Dynamic Memory - Let VMs adjust RAM based on demand

Key Cmdlets

TaskCmdlet
List VMsGet-VM
Create VMNew-VM -Name X -Generation 2
Start/StopStart-VM / Stop-VM
CheckpointCheckpoint-VM -SnapshotName X
SwitchesGet-VMSwitch / New-VMSwitch
Module 4 takeaways Hyper-V RoleType 1, bare-metal VM GenerationsGen2 default for modern vSwitchesExternal/Internal/Private Checkpointstest, not backup PowerShellNew/Get/Set-VM Ready for Hyper-V labs and quiz