WSA M04: Hyper-V Virtualization

← Course Home Start GUI Lab →

Module 04: Hyper-V Virtualization

One host, many isolated VMs — Hyper-V is how Windows Server runs the data center.

What you'll learn

  • Hypervisor types — Type 1 (bare-metal) vs Type 2 (hosted)
  • VM generations — Gen 1 (BIOS) vs Gen 2 (UEFI, modern)
  • Virtual switches — External, Internal, Private
  • Checkpoints — point-in-time recovery without backups
  • PS VM management ★ — New-VM, Set-VM, Start-VM at scale
Where this fits: Foundation #4 — virtualization. CTS1328C Objective #3. AZ-800 domain: VMs & containers (15-20%). PowerShell VM management (★) is how you scale Hyper-V past one host.
Module 04 — your journey 1Hypervisor Types 2VM Generations 3Virtual Switches 4Switch Types 5Checkpoints 6Restore 7New-VM 8Set-VM 9PS VM Mgmt ★ → next: M05 — Containers

Hypervisor Types

Type 1 (Bare-Metal)

  • Runs directly on hardware (no host OS)
  • Better performance, smaller attack surface
  • Examples: Hyper-V, VMware ESXi

Type 2 (Hosted)

  • Runs on top of a host OS
  • Easier to install, extra overhead
  • Examples: VirtualBox, VMware Workstation

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
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

Virtual Switches — Internal & Private

Internal keeps VMs on the host network only; Private isolates VMs even from the host. Use these for test labs and malware analysis.

# Host-to-VM only (no physical network) PS C:\> New-VMSwitch -Name "Internal" -SwitchType Internal
# VM-to-VM only (no host, no LAN) PS C:\> New-VMSwitch -Name "Private" -SwitchType Private
→ continued — context from prev slide 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 = point-in-time VM state you can revert to. Two types: Standard (memory + disk, for dev/test) vs Production (VSS-based, application-consistent, default in Windows Server).

# Save + list checkpoints PS C:\> Checkpoint-VM -Name "DC02" -SnapshotName "Before Updates" PS C:\> Get-VMCheckpoint -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

Checkpoints — restore and cleanup

Creating checkpoints is easy. Restoring them is the moment that matters. Restore-VMCheckpoint rolls a VM back to a saved state, and the cmdlets that follow handle cleanup so checkpoints don't accumulate.

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"
→ continued — context from prev slide 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

List every VM on this host, then create a new Gen 2 VM with a dynamically-expanding VHDX. Output table shown in the right-panel demo.

# List all virtual machines on this host PS C:\> Get-VM
# 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.)

Power, tuning, and networking — full lifecycle in one chain. Add -Force on Stop-VM for immediate power-off. Right panel shows the full cmdlet flow.

# Power: start / graceful stop / force off PS C:\> Start-VM -Name "WebServer" PS C:\> Stop-VM -Name "WebServer" # add -Force for hard off # Tune CPU + memory; attach to vSwitch PS C:\> Set-VM -Name "WebServer" -ProcessorCount 4 -DynamicMemory PS C:\> Connect-VMNetworkAdapter -VMName "WebServer" -SwitchName "External"
→ continued — context from prev slide 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