Introduction to Hyper-V Virtual Machine Management

Once the Hyper-V role is installed and your virtual switches are configured on Windows Server 2022, the next step is creating and managing virtual machines. Hyper-V supports two VM generations with different firmware and device models, offers granular control over CPU, memory, and storage allocation, and provides checkpoint functionality for rollback and testing. This guide covers the full VM lifecycle using PowerShell and Hyper-V Manager, including creation, configuration, cloning, and physical-to-virtual migration.

VM Generations: Generation 1 vs Generation 2

Hyper-V on Windows Server 2022 supports two virtual machine generations, and the choice is made at creation time — it cannot be changed afterward. Generation 1 VMs use a BIOS-based firmware and emulated devices including an IDE controller, an emulated PS/2 keyboard and mouse, a legacy NIC, and a VGA video adapter. Generation 1 supports booting from IDE-attached VHDs and supports a wider range of operating systems, including 32-bit Windows and older Linux distributions.

Generation 2 VMs use UEFI firmware with Secure Boot support, synthetic devices only (no emulated IDE), and support for larger boot volumes (beyond 2 TB for the boot disk). Generation 2 also supports PXE boot from a synthetic network adapter, which is not available in Generation 1. For modern 64-bit Windows guest operating systems (Windows Server 2012 and later, Windows 8 and later) and supported Linux distributions, Generation 2 is the recommended choice due to faster boot times and UEFI Secure Boot capability. For older operating systems, Generation 1 remains necessary.

Creating a Virtual Machine with New-VM

The New-VM cmdlet creates a new virtual machine. The minimum required parameters are a VM name, but you should also specify memory, generation, and a virtual hard disk at creation time. The following example creates a Generation 2 VM with 4 GB of startup RAM and a new 80 GB VHDX disk:

New-VM -Name "WebServer01" `
       -MemoryStartupBytes 4GB `
       -Generation 2 `
       -NewVHDPath "D:HyperVVHDsWebServer01.vhdx" `
       -NewVHDSizeBytes 80GB `
       -SwitchName "ExternalSwitch"

To create a VM using an existing VHD or VHDX file (for example, a sysprepped template disk):

New-VM -Name "AppServer01" `
       -MemoryStartupBytes 8GB `
       -Generation 2 `
       -VHDPath "D:HyperVTemplatesWS2022-Template.vhdx" `
       -SwitchName "ExternalSwitch"

To create a VM without any disk (you will attach storage separately):

New-VM -Name "TestVM01" -MemoryStartupBytes 2GB -Generation 2 -NoVHD

Configuring VM Memory

Hyper-V supports both static and dynamic memory allocation. Static memory assigns a fixed amount of RAM to a VM that never changes during runtime. Dynamic Memory allows Hyper-V to adjust the VM’s allocated RAM within a minimum-maximum range based on demand, improving host memory utilisation when VMs are lightly loaded.

Configure static memory:

Set-VMMemory -VMName "WebServer01" -DynamicMemoryEnabled $false -StartupBytes 4GB

Enable Dynamic Memory with minimum, maximum, and buffer settings:

Set-VMMemory -VMName "WebServer01" `
             -DynamicMemoryEnabled $true `
             -MinimumBytes 512MB `
             -StartupBytes 2GB `
             -MaximumBytes 8GB `
             -Buffer 20 `
             -Priority 80

The -Buffer parameter specifies the percentage of memory Hyper-V should attempt to keep available above the VM’s current demand, and -Priority (1-100) controls how Hyper-V distributes available memory among competing VMs when the host is under pressure. Check memory settings for a VM:

Get-VMMemory -VMName "WebServer01"

Configuring Virtual Processors

By default, new VMs are created with a single virtual processor. Most server workloads benefit from more vCPUs. The Set-VMProcessor cmdlet controls CPU allocation:

Set-VMProcessor -VMName "WebServer01" -Count 4

You can also configure NUMA topology, reserve a percentage of host CPU cycles for the VM, and set maximum CPU usage limits:

Set-VMProcessor -VMName "WebServer01" `
                -Count 4 `
                -Reserve 10 `
                -Maximum 80 `
                -RelativeWeight 100

The -Reserve parameter ensures the VM always has access to at least 10% of host CPU cycles. The -Maximum parameter caps the VM at 80% of total host CPU. -RelativeWeight determines priority when multiple VMs compete for CPU resources. View current processor settings:

Get-VMProcessor -VMName "WebServer01"

Adding and Managing Virtual Hard Disks

Virtual hard disks in Hyper-V use the VHDX format by default (maximum size 64 TB, with journaling for data integrity) or the legacy VHD format (maximum 2 TB). Create a new VHDX data disk and attach it to a VM:

New-VHD -Path "D:HyperVVHDsWebServer01-Data.vhdx" -SizeBytes 200GB -Dynamic
Add-VMHardDiskDrive -VMName "WebServer01" -Path "D:HyperVVHDsWebServer01-Data.vhdx"

For Generation 2 VMs, all disks attach to a SCSI controller. For Generation 1 VMs, the boot disk typically attaches to the IDE controller and data disks can use SCSI. List the hard disk drives attached to a VM:

Get-VMHardDiskDrive -VMName "WebServer01"

Expand an existing VHDX disk (VM must be stopped for fixed disks; dynamic disks can be expanded online on supported guest OSes):

Resize-VHD -Path "D:HyperVVHDsWebServer01-Data.vhdx" -SizeBytes 400GB

To create a differencing disk (stores only changes relative to a parent disk, useful for rapid VM cloning from a template):

New-VHD -Path "D:HyperVVHDsClone01.vhdx" `
        -ParentPath "D:HyperVTemplatesWS2022-Template.vhdx" `
        -Differencing

Starting, Stopping, and Managing VM State

The basic VM state management cmdlets cover all lifecycle operations. Start a VM:

Start-VM -Name "WebServer01"

Shut down a VM gracefully using integration services (requires the guest OS to be running and responsive):

Stop-VM -Name "WebServer01"

Force a hard power-off (equivalent to pulling the power, use only when the guest is unresponsive):

Stop-VM -Name "WebServer01" -Force -TurnOff

Save a VM to disk (hibernate the VM, preserving memory state to the VHD location):

Save-VM -Name "WebServer01"

Pause and resume a VM (suspends scheduling without saving memory to disk):

Suspend-VM -Name "WebServer01"
Resume-VM -Name "WebServer01"

List all VMs and their current state:

Get-VM | Select-Object Name, State, CPUUsage, MemoryAssigned, Uptime

Checkpoint Management

Checkpoints (formerly called snapshots) capture the state of a VM at a point in time, including CPU state, memory, and disk contents, allowing you to roll back to that point if something goes wrong. There are two checkpoint types in Hyper-V: Standard checkpoints capture memory state and the disk delta, and Production checkpoints use Volume Shadow Copy Service inside the guest to create an application-consistent backup without capturing live memory state. Production checkpoints are suitable for production workloads because they do not freeze the VM to capture memory.

Configure the checkpoint type:

Set-VM -VMName "WebServer01" -CheckpointType Production

Create a checkpoint:

Checkpoint-VM -Name "WebServer01" -SnapshotName "Before-PatchTuesday-2026-05"

List all checkpoints for a VM:

Get-VMCheckpoint -VMName "WebServer01"

Restore a VM to a specific checkpoint (stop the VM first):

Stop-VM -Name "WebServer01"
Get-VMCheckpoint -VMName "WebServer01" -Name "Before-PatchTuesday-2026-05" | Restore-VMCheckpoint

Delete a checkpoint (merges the delta disk back into the parent):

Get-VMCheckpoint -VMName "WebServer01" -Name "Before-PatchTuesday-2026-05" | Remove-VMCheckpoint

In production environments, checkpoints should not be left in place for extended periods. Each checkpoint creates a differencing disk chain that grows over time and degrades VM disk performance. Always remove checkpoints after they are no longer needed.

Exporting and Importing Virtual Machines

Exporting a VM creates a self-contained copy of all VM files (configuration, VHDX disks, and any checkpoints) into a folder. This export can then be imported on any Hyper-V host, making it a useful method for VM cloning and migration without a shared storage infrastructure.

Export a VM (the VM can be running during export if it has no production checkpoints, but a stopped VM gives a consistent copy):

Export-VM -Name "WebServer01" -Path "D:HyperVExports"

The export creates the folder D:HyperVExportsWebServer01. Import the VM on a destination Hyper-V host. There are three import types: Register (use files in place), Restore (copy files to the default Hyper-V paths), and Copy (copy files and generate new unique IDs, allowing the same VM to exist on multiple hosts simultaneously):

# Register in-place (no copy)
Import-VM -Path "D:HyperVExportsWebServer01Virtual Machines.vmcx"

# Copy with new unique ID (for cloning)
Import-VM -Path "D:HyperVExportsWebServer01Virtual Machines.vmcx" `
          -Copy `
          -GenerateNewId `
          -VirtualMachinePath "D:HyperVVMs" `
          -VhdDestinationPath "D:HyperVVHDs"

Removing a Virtual Machine

To delete a VM permanently, stop it first, then use Remove-VM. Note that Remove-VM by default removes only the VM configuration — the VHDX files remain on disk. Use -Force to suppress the confirmation prompt:

Stop-VM -Name "TestVM01" -TurnOff
Remove-VM -Name "TestVM01" -Force

To also delete the VHDX files, retrieve their paths before removing the VM and then delete them:

$vhdPaths = Get-VMHardDiskDrive -VMName "TestVM01" | Select-Object -ExpandProperty Path
Remove-VM -Name "TestVM01" -Force
$vhdPaths | ForEach-Object { Remove-Item -Path $_ -Force }

Physical to Virtual Migration with Disk2VHD

Microsoft’s Disk2VHD utility (available as a free download from the Sysinternals suite) converts a live physical machine’s disks into VHD or VHDX files while the system is running, using Volume Shadow Copy. Run Disk2VHD on the physical machine you want to virtualise, select the volumes to include, choose VHDX format, and specify an output path on a network share or external disk accessible to the Hyper-V host. After conversion, create a new Generation 1 VM on the Hyper-V host (Generation 1 is required for P2V migrations since the physical machine’s hardware drivers are BIOS-based), attach the converted VHDX as the boot disk, and start the VM. Windows will detect hardware changes and install the appropriate Hyper-V synthetic drivers through Windows Update on first boot.

disk2vhd.exe C: D: \HyperV-HostExportsPhysicalServer.vhdx

Attaching an ISO for Guest OS Installation

To install an operating system in a new VM, attach a DVD drive with an ISO file before starting the VM:

Add-VMDvdDrive -VMName "WebServer01" -Path "D:ISOsWS2022_Eval.iso"

For Generation 2 VMs, also ensure the boot order places the DVD drive first:

$dvd = Get-VMDvdDrive -VMName "WebServer01"
Set-VMFirmware -VMName "WebServer01" -FirstBootDevice $dvd

After installation completes, remove the DVD drive:

Remove-VMDvdDrive -VMName "WebServer01" -ControllerNumber 0 -ControllerLocation 1

Conclusion

Hyper-V on Windows Server 2022 provides a comprehensive set of PowerShell cmdlets and a graphical management interface for creating and managing virtual machines across their entire lifecycle. Understanding the difference between VM generations, using Dynamic Memory to improve host efficiency, and leveraging production checkpoints for safe maintenance windows are key skills for any Hyper-V administrator. Export/import functionality and tools like Disk2VHD also make migrating workloads into the virtual environment straightforward. The following guides in this series build on this foundation to cover virtual networking, live migration, and Hyper-V Replica.