PowerShell Lab Complete!

You've mastered Hyper-V management with PowerShell!

Take the Quiz → Try GUI Lab
Hyper-V Cmdlet Module:
Use Get-Command -Module Hyper-V to see all available cmdlets. Common verbs: Get, Set, New, Add, Remove, Start, Stop, Checkpoint, Export, Import.
Tip: Always use -WhatIf with destructive commands like Remove-VM to preview the action before executing.
Generation 1 vs 2:
Gen 2 VMs support UEFI firmware, Secure Boot, and VHDX boot disks. Gen 1 VMs use legacy BIOS and are needed for older OS versions.
Virtual Switch Types:
External - Connects VMs to the physical network
Internal - Connects VMs and the host (no physical access)
Private - Connects VMs only (host is isolated)
Checkpoint Types:
Standard - Captures VM state, memory, and disk (default).
Production - Uses VSS inside the guest for application-consistent snapshots. Use Set-VM -CheckpointType to configure.
Live Migration Requirements:
- Shared storage (CSV or SMB 3.0) or live storage migration
- Compatible processor versions between hosts
- Same virtual switch names on source and destination
- Both hosts must be domain-joined or trust each other
- Use Move-VM to initiate a live migration
VHD vs VHDX: VHDX supports up to 64 TB disks, has 4 KB sector alignment, and includes corruption protection via metadata logging. VHD is limited to 2 TB and lacks these modern features. Always prefer VHDX for new deployments.

VM Discovery & Information

1. List Virtual Machines
View all VMs on the Hyper-V host and their current state.
Get-VM
2. Get Host Information
View the Hyper-V host configuration, including default paths and settings.
Get-VMHost
3. Measure VM Resource Usage
View resource metering data for a running VM (CPU, memory, network).
Measure-VM -Name "DC02"

VM Creation & Configuration

4. Create a New VM
Create a new Generation 2 VM with 2 GB startup RAM.
New-VM -Name "TEST01" -Generation 2 -MemoryStartupBytes 2GB
5. Configure VM Settings
Modify processor count for an existing VM.
Set-VM -Name "TEST01" -ProcessorCount 4
6. Configure Dynamic Memory
Enable dynamic memory and set minimum/maximum thresholds.
Set-VMMemory -VMName "TEST01" -DynamicMemoryEnabled $true -MinimumBytes 512MB -MaximumBytes 4GB

Storage Management

7. Create a Virtual Hard Disk
Create a new dynamically expanding VHDX file (60 GB max).
New-VHD -Path "C:\VMs\TEST01\Disk1.vhdx" -SizeBytes 60GB -Dynamic
8. Attach a VHD to a VM
Add the newly created disk to the VM's SCSI controller.
Add-VMHardDiskDrive -VMName "TEST01" -Path "C:\VMs\TEST01\Disk1.vhdx"

Virtual Networking

9. View Virtual Switches
List all virtual switches configured on the host.
Get-VMSwitch
10. Create a Virtual Switch
Create a new internal virtual switch for lab use.
New-VMSwitch -Name "LabSwitch" -SwitchType Internal
11. Connect VM to Switch
Attach a VM's network adapter to a specific virtual switch.
Set-VMNetworkAdapter -VMName "TEST01" -SwitchName "LabSwitch"

VM Operations & Protection

12. Start a VM
Power on an existing virtual machine.
Start-VM -Name "WEB01"
13. Create a Checkpoint
Create a checkpoint (snapshot) before applying updates.
Checkpoint-VM -Name "DC02" -SnapshotName "Before Update"
14. Export a VM
Export a VM for backup or migration to another host.
Export-VM -Name "DC02" -Path "D:\Backups"