Cheat Sheets

Hyper-V PowerShell Cheat Sheet: VMs, Checkpoints, Switches (PDF)

Every button in Hyper-V Manager has a PowerShell cmdlet behind it. The cmdlet is the version you can script, run on Server Core and paste into a runbook. This Hyper-V PowerShell cheat sheet collects the ones you reach for on a Windows Server 2025 host, grouped by job, with the parameters that trip people up.

Original content from computingforgeeks.com - post 194204

The tables cover New-VM, Set-VMProcessor for nested virtualization, checkpoints, the three VMSwitch types, Export-VM and Import-VM, Enable-VMIntegrationService and Get-VM | Measure-VM, and the sections below explain each group. Every cmdlet and parameter here was checked in November 2026 against Microsoft’s Hyper-V module reference for Windows Server 2025.

Hyper-V PowerShell cheat sheet

Run every row from an elevated PowerShell window on the Hyper-V host, or from a management machine with the Hyper-V module and -ComputerName added. The examples use a VM called web01, a data path on D:\Hyper-V and an internal switch called LabNAT; swap in your own names. Most configuration cmdlets (processor count, nested virtualization, memory type) refuse to change a running VM, so stop it first when PowerShell says the operation is not allowed in the current state.

Install the role and inspect the host

CommandWhat it does
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -RestartInstall the Hyper-V role on Windows Server and reboot
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -AllEnable Hyper-V on Windows 11 Pro or Enterprise
Get-WindowsFeature -Name Hyper-V*Show which Hyper-V features are installed
Get-Command -Module Hyper-VList every cmdlet the module ships
Get-VMHost | Format-List VirtualMachinePath, VirtualHardDiskPathShow the default VM and disk folders
Set-VMHost -VirtualMachinePath D:\Hyper-V -VirtualHardDiskPath D:\Hyper-V\DisksMove the defaults off the system drive

Create and configure VMs

CommandWhat it does
New-VM -Name web01 -Generation 2 -MemoryStartupBytes 2GB -NewVHDPath D:\Hyper-V\Disks\web01.vhdx -NewVHDSizeBytes 60GB -SwitchName LabNATCreate a Gen 2 VM with a new dynamic disk on a switch
Get-VMList VMs with state, CPU, memory and uptime
Set-VMProcessor -VMName web01 -Count 2Give the VM two virtual processors
Set-VMMemory -VMName web01 -DynamicMemoryEnabled $true -MinimumBytes 1GB -MaximumBytes 4GBTurn on dynamic memory with a floor and ceiling
Add-VMDvdDrive -VMName web01 -Path D:\ISO\server.isoAttach an install ISO
Set-VMFirmware -VMName web01 -FirstBootDevice (Get-VMDvdDrive -VMName web01)Boot a Gen 2 VM from the DVD first
Set-VMFirmware -VMName web01 -EnableSecureBoot OffDisable Secure Boot on a Gen 2 VM
Set-VM -Name web01 -AutomaticStartAction Start -AutomaticStopAction ShutDownStart with the host, shut down cleanly with it
Rename-VM -Name web01 -NewName web02Rename a VM
Remove-VM -Name web01 -ForceDelete the VM configuration; the VHDX files stay on disk

Start, stop and save

CommandWhat it does
Start-VM -Name web01Power the VM on
Stop-VM -Name web01Shut down through the guest OS
Stop-VM -Name web01 -TurnOffPull the virtual power cord
Save-VM -Name web01Save memory state to disk, like hibernate
Suspend-VM -Name web01Pause the VM in memory
Resume-VM -Name web01Continue a paused VM
Restart-VM -Name web01 -ForceHard reset with no prompt, like a power cycle; can lose data

Nested virtualization

CommandWhat it does
Set-VMProcessor -VMName hv01 -ExposeVirtualizationExtensions $truePass VT-x or AMD-V to a stopped VM
Get-VMProcessor -VMName hv01 | Select-Object VMName, ExposeVirtualizationExtensionsConfirm the setting took
Get-VMNetworkAdapter -VMName hv01 | Set-VMNetworkAdapter -MacAddressSpoofing OnLet nested guests reach the network
Set-VMProcessor -VMName hv01 -ExposeVirtualizationExtensions $falseTurn nesting off again (VM stopped)

Checkpoints

CommandWhat it does
Set-VM -Name web01 -CheckpointType ProductionUse VSS-based checkpoints, fall back to standard
Set-VM -Name web01 -CheckpointType ProductionOnlyFail instead of falling back to standard
Checkpoint-VM -Name web01 -SnapshotName before-patchTake a named checkpoint
Get-VMSnapshot -VMName web01List checkpoints with type and creation time
Restore-VMSnapshot -VMName web01 -Name before-patch -Confirm:$falseRoll back to a checkpoint
Remove-VMSnapshot -VMName web01 -Name before-patchDelete a checkpoint and merge its disk
Remove-VMSnapshot -VMName web01 -Name base -IncludeAllChildSnapshotsDelete a checkpoint and every child under it
Set-VM -Name web01 -AutomaticCheckpointsEnabled $falseTurn off automatic checkpoints for the VM

Virtual switches and VM networking

CommandWhat it does
Get-VMSwitchList switches and their type
New-VMSwitch -Name External -NetAdapterName Ethernet -AllowManagementOS $trueExternal switch bound to a physical NIC, host keeps access
New-VMSwitch -Name LabNAT -SwitchType InternalInternal switch: VMs plus the host
New-VMSwitch -Name Isolated -SwitchType PrivatePrivate switch: VMs only, no host
New-NetNat -Name LabNAT -InternalIPInterfaceAddressPrefix 192.168.100.0/24NAT the internal subnet out through the host
Connect-VMNetworkAdapter -VMName web01 -SwitchName LabNATMove a VM’s NIC to another switch
Add-VMNetworkAdapter -VMName web01 -SwitchName IsolatedAdd a second NIC
Set-VMNetworkAdapterVlan -VMName web01 -Access -VlanId 20Tag the VM’s traffic with VLAN 20
Get-VMNetworkAdapter -VMName web01Show switch, MAC and IP addresses per NIC

Export, import and disks

CommandWhat it does
Export-VM -Name web01 -Path E:\ExportExport config, checkpoints and disks to a folder
Import-VM -Path $vmcxRegister an exported VM in place
Import-VM -Path $vmcx -Copy -GenerateNewIdCopy into the host defaults with a new VM ID
Compare-VM -Path $vmcxReport what blocks an import on this host
New-VHD -Path D:\Hyper-V\Disks\data01.vhdx -SizeBytes 100GB -DynamicCreate a dynamically expanding VHDX
Add-VMHardDiskDrive -VMName web01 -Path D:\Hyper-V\Disks\data01.vhdxAttach the disk to a VM
Resize-VHD -Path D:\Hyper-V\Disks\data01.vhdx -SizeBytes 150GBGrow a virtual disk; extend the partition in the guest after
Get-VHD -Path D:\Hyper-V\Disks\data01.vhdxShow type, size on disk and maximum size

Integration services and guest access

CommandWhat it does
Get-VMIntegrationService -VMName web01List integration services and whether each is on
Enable-VMIntegrationService -VMName web01 -Name 'Guest Service Interface'Turn on host to guest file copy
Disable-VMIntegrationService -VMName web01 -Name 'Time Synchronization'Stop the host setting the guest clock
Copy-VMFile -Name web01 -SourcePath C:\Temp\app.zip -DestinationPath C:\Temp\app.zip -CreateFullPath -FileSource HostCopy a file from host into the guest
Enter-PSSession -VMName web01 -Credential (Get-Credential)PowerShell Direct shell, no network needed
Invoke-Command -VMName web01 -Credential $cred -ScriptBlock { hostname }Run one command in the guest over the VM bus

Monitoring and resource metering

CommandWhat it does
Get-VM | Select-Object Name, State, CPUUsage, MemoryAssigned, UptimeQuick live view of every VM
Get-VM | Enable-VMResourceMeteringStart collecting usage for all VMs
Get-VM | Measure-VMCPU, disk and network usage since metering started
Measure-VM -VMName web01 | Format-List *Every metered field for one VM
Reset-VMResourceMetering -VMName web01Zero the counters and start a new period
Disable-VMResourceMetering -VMName web01Stop collecting

Three rows use $vmcx and $cred because the real values are long or secret: the export section below shows how to fill $vmcx, and $cred = Get-Credential holds the guest login for PowerShell Direct. Everything else is literal and safe to paste once the names match your host.

How do you create a VM with New-VM?

One New-VM line creates the VM, its disk and its network connection, and the only parameter you should never leave out is -Generation. Generation 2 gives you UEFI, Secure Boot and SCSI boot, and you cannot convert a VM between generations later, so set it explicitly instead of trusting whatever the default turns out to be:

New-VM -Name web01 -Generation 2 -MemoryStartupBytes 2GB -NewVHDPath D:\Hyper-V\Disks\web01.vhdx -NewVHDSizeBytes 60GB -SwitchName LabNAT

-NewVHDPath and -NewVHDSizeBytes go together and produce a dynamically expanding VHDX, so the 60 GB is a ceiling, not space taken on day one. Without -MemoryStartupBytes the VM gets 512 MB, which is too little for a Windows Server guest to install. The VM also starts with one virtual processor, so add CPUs and the install media before the first boot:

Set-VMProcessor -VMName web01 -Count 2
Add-VMDvdDrive -VMName web01 -Path D:\ISO\server.iso
Set-VMFirmware -VMName web01 -FirstBootDevice (Get-VMDvdDrive -VMName web01)
Start-VM -Name web01

If the guest is a Linux distribution and it refuses to boot with a Secure Boot violation, the VM is using the Windows-only Secure Boot template. Either switch Secure Boot off with Set-VMFirmware -VMName web01 -EnableSecureBoot Off or keep it on and move the VM to the UEFI CA template with Set-VMFirmware -VMName web01 -SecureBootTemplate MicrosoftUEFICertificateAuthority. That template trusts the Microsoft-signed shim that distributions load first; Canonical’s Ubuntu Secure Boot documentation describes that chain, with the shim signed by Microsoft and GRUB and the kernel signed by Canonical. Before you start the guest install, check these on the host:

  • Get-VM -Name web01 | Select-Object Name, Generation, ProcessorCount reports Generation 2 and the CPU count you set.
  • Get-VMDvdDrive -VMName web01 shows the ISO path you attached.
  • Get-VMNetworkAdapter -VMName web01 lists the adapter on the switch you named.

For a host you manage only from a browser, the same VM settings are available in Windows Admin Center on Windows Server 2025, which calls these cmdlets for you.

How do you enable nested virtualization with Set-VMProcessor?

Nested virtualization is one switch on the VM’s processor, -ExposeVirtualizationExtensions, and the VM must be off when you flip it. Microsoft supports it on Intel hosts running Windows Server 2016 or later with VM configuration version 8.0 or higher, and on AMD EPYC or Ryzen hosts running Windows Server 2022 or later with configuration version 9.3 or higher. Stop the VM, then set it:

Stop-VM -Name hv01
Set-VMProcessor -VMName hv01 -ExposeVirtualizationExtensions $true
Get-VMNetworkAdapter -VMName hv01 | Set-VMNetworkAdapter -MacAddressSpoofing On
Start-VM -Name hv01

The MAC spoofing line matters as much as the processor flag. Guests inside hv01 send frames with their own MAC addresses through the outer VM’s adapter, and the outer switch drops them unless spoofing is on for that adapter. When you cannot allow spoofing, for example on a cloud VM, build an internal switch with NAT inside hv01 instead, the same pattern as the LabNAT switch below. Memory is the other surprise: while Hyper-V runs inside the VM, its memory cannot be resized at runtime even with dynamic memory enabled, so give it enough RAM before you start it. Confirm the flag before you install the Hyper-V role inside the guest:

Get-VMProcessor -VMName hv01 | Select-Object VMName, ExposeVirtualizationExtensions

A value of True means the guest will see the virtualization extensions on its next boot, and Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart inside it will then pass the processor check. Nested Hyper-V suits labs, training and container isolation; Microsoft’s own guidance keeps failover clustering and performance-sensitive workloads off it. Check the cloud before you plan a nested lab there, too: Google’s Compute Engine nested virtualization overview states that Linux KVM is the only hypervisor supported in an L1 VM, so Hyper-V will not start inside a Windows VM on GCP.

Which checkpoint type should you use?

Use production checkpoints for any server that holds data; we treat that as the default. A production checkpoint asks the guest to flush through VSS (or the file system freeze on Linux), so restoring it is like booting after a clean shutdown. A standard checkpoint also captures memory, which restores the VM exactly where it was, open files and half-written transactions included. That is handy on a test box and a bad idea on a database server, which then has two copies of the truth when it reconnects. Set-VM -CheckpointType takes four values:

  • Production uses VSS and quietly falls back to a standard checkpoint if the guest cannot do it.
  • ProductionOnly uses VSS and fails the checkpoint rather than falling back.
  • Standard saves disk and memory state.
  • Disabled blocks checkpoints for that VM entirely.

We’d set ProductionOnly on database and domain controller VMs, because a silent fallback to a memory checkpoint is exactly the case you wanted to avoid. Take a named checkpoint before a risky change, then list them:

Set-VM -Name web01 -CheckpointType ProductionOnly
Checkpoint-VM -Name web01 -SnapshotName before-patch
Get-VMSnapshot -VMName web01

The cmdlets still say “snapshot” because checkpoints were called snapshots until Windows Server 2012 R2; -SnapshotName also answers to -CheckpointName. Restore-VMSnapshot asks for confirmation unless you pass -Confirm:$false, and Remove-VMSnapshot merges the differencing disk back into its parent, which takes disk I/O proportional to how much changed. A checkpoint is not a backup: it lives on the same storage as the VM and dies with it.

Which VMSwitch type do you need?

Pick by who has to talk to the VM. New-VMSwitch builds all three types, but external is not a -SwitchType value: you get it by naming a physical adapter with -NetAdapterName.

TypeWho can reach the VMTypical use
ExternalThe physical LAN, the host (with -AllowManagementOS $true) and other VMsServers your users connect to
InternalThe host and other VMs on the switch; add WinNAT for outbound accessLab networks on a laptop or a single NIC host
PrivateOnly other VMs on the same switchIsolated test networks, cluster heartbeat in a lab

Create an external switch from the console or iLO/iDRAC, not over a remote session on that same NIC. With -AllowManagementOS $true the host’s IP configuration moves to a new vEthernet (External) adapter, and your RDP or WinRM session rides on the adapter being rebound:

Get-NetAdapter
New-VMSwitch -Name External -NetAdapterName Ethernet -AllowManagementOS $true

An internal switch with NAT is the usual lab setup, because VMs get outbound internet through the host without touching the LAN. Give the host side of the switch the gateway address, then create the NAT for the subnet:

New-VMSwitch -Name LabNAT -SwitchType Internal
New-NetIPAddress -IPAddress 192.168.100.1 -PrefixLength 24 -InterfaceAlias 'vEthernet (LabNAT)'
New-NetNat -Name LabNAT -InternalIPInterfaceAddressPrefix 192.168.100.0/24

WinNAT does not hand out addresses, so each VM on LabNAT needs a static IP in 192.168.100.0/24, gateway 192.168.100.1 and a DNS server, unless you run DHCP on that subnet yourself. Microsoft’s NAT guide also limits a host to one NAT network, so plan one internal NAT switch per host rather than one per project. On a host that also runs Docker or Windows containers, run Get-NetNat first, because the container engine creates a NAT network of its own and a second one leaves WinNAT in a state Microsoft’s guide tells you to clean up. Check the result with this list:

  • Get-VMSwitch shows LabNAT with SwitchType Internal.
  • Get-NetIPAddress -InterfaceAlias 'vEthernet (LabNAT)' shows 192.168.100.1.
  • Get-NetNat lists the 192.168.100.0/24 prefix.

Containers use the same switch and NAT machinery, which is why Docker on Windows Server 2025 creates its own NAT network on first start.

How do you move a VM with Export-VM and Import-VM?

Export-VM writes a self-contained folder with the configuration, the virtual disks and any checkpoints, and Import-VM on the other host reads it back. The export lands in a subfolder named after the VM, with Virtual Machines, Virtual Hard Disks and Snapshots inside:

Export-VM -Name web01 -Path E:\Export

Import needs the path to the .vmcx file, whose name is the VM’s GUID. Look it up instead of typing it, and run Compare-VM first so a missing switch or an unsupported configuration version shows up as a report rather than a failed import:

$vmcx = (Get-ChildItem 'E:\Export\web01\Virtual Machines' -Filter *.vmcx).FullName
Compare-VM -Path $vmcx
Import-VM -Path $vmcx -Copy -GenerateNewId

The flags decide what happens to the files. A bare Import-VM -Path $vmcx registers the VM where the files sit, so the export folder becomes the live VM folder. -Copy copies everything into the host’s default VM and disk paths and leaves the export untouched. -GenerateNewId gives the copy a fresh ID, which you need when the original is still registered on the same host or cluster. Both machines cannot share an ID, so importing a copy next to its source without -GenerateNewId fails. To export a running VM, add -CaptureLiveState CaptureDataConsistentState to Export-VM; that uses production checkpoint technology instead of saving memory.

How do you turn on Guest Service Interface?

Run Enable-VMIntegrationService with the service’s display name. Guest Service Interface is the one integration service Hyper-V leaves off for Windows guests, and Copy-VMFile needs it to push a file into the VM without a network share:

Get-VMIntegrationService -VMName web01
Enable-VMIntegrationService -VMName web01 -Name 'Guest Service Interface'

The list you get back holds six services, and each one does a specific job for the host:

  • Guest Service Interface lets the host copy files into the guest.
  • Heartbeat reports whether the guest OS is responding.
  • Key-Value Pair Exchange passes guest details such as its IP addresses to the host.
  • Shutdown lets Stop-VM shut the guest down cleanly.
  • Time Synchronization sets the guest clock from the host.
  • VSS makes production checkpoints and host-level backups consistent.

We leave Heartbeat, Shutdown and VSS on everywhere, because checkpoints and clean shutdowns depend on them. The one people do switch off is Time Synchronization on a domain controller that should take time from its domain hierarchy, a choice covered in our Active Directory Domain Services install. With the guest interface on, copy a file in:

Copy-VMFile -Name web01 -SourcePath C:\Temp\app.zip -DestinationPath C:\Temp\app.zip -CreateFullPath -FileSource Host

-FileSource Host is mandatory and is the only direction the cmdlet supports. To run commands inside the guest instead, PowerShell Direct talks over the VM bus with no network at all. It needs the VM running on the local host, a Windows Server 2016 or Windows 10 guest or newer, and the guest’s own credentials:

$cred = Get-Credential
Invoke-Command -VMName web01 -Credential $cred -ScriptBlock { Get-NetIPAddress -AddressFamily IPv4 }

That is the fastest way to fix a guest whose network config you just broke, since the session does not depend on the network you broke.

How do you measure VM usage with Get-VM | Measure-VM?

Turn on resource metering first, because Measure-VM returns nothing useful until it is enabled. Metering then accumulates average CPU in MHz, memory, total disk allocation and network traffic per VM until you reset it. We use it to answer “which VM is eating this host” and to bill a tenant for a month:

Get-VM | Enable-VMResourceMetering
Get-VM | Measure-VM

The default table shows VMName, AvgCPU(MHz), AvgRAM(M), MaxRAM(M), MinRAM(M), TotalDisk(M), NetworkInbound(M) and NetworkOutbound(M). The RAM columns are short labels for longer property names, and MeteringDuration is not in the table at all, so select them by name when you script against the output:

Get-VM | Measure-VM | Select-Object VMName, AverageMemoryUsage, MaximumMemoryUsage, MinimumMemoryUsage, MeteringDuration

Read the numbers with two caveats. A VM on static memory reports the same value for average, maximum and minimum, because it holds its full allocation the whole time, so the memory columns only tell you something on dynamic memory VMs. TotalDisk counts every attached VHD plus the space checkpoints take, so a VM with an old checkpoint chain looks bigger than its guest thinks it is. Call Reset-VMResourceMetering -VMName web01 at the start of each billing or review period. For a live snapshot without metering, Get-VM | Select-Object Name, State, CPUUsage, MemoryAssigned, Uptime is enough.

Check a new Hyper-V host in eight commands

After a fresh Windows Server 2025 install and the Hyper-V role, run these in order. Each one has a result you can see, and together they cover the settings people forget until a disk fills or a VM fails to come back after a host reboot:

  1. Get-WindowsFeature -Name Hyper-V* shows Hyper-V and its PowerShell module as Installed.
  2. Get-VMHost | Format-List VirtualMachinePath, VirtualHardDiskPath points at a data volume, not C:.
  3. Get-VMSwitch lists the switch your VMs will use, with the type you meant.
  4. Get-VM | Select-Object Name, Generation, CheckpointType shows Generation 2 and a production checkpoint type on server VMs.
  5. Get-VM | Select-Object Name, AutomaticStartAction, AutomaticStopAction matches how each VM should behave on a host reboot.
  6. Get-VM | Get-VMSnapshot returns only checkpoints you meant to keep.
  7. Get-VMIntegrationService -VMName web01 shows Heartbeat, Shutdown and VSS enabled.
  8. Get-VM | Measure-VM returns numbers, which proves metering is on.

If you would rather click than type for day-to-day work, the HV Manager web interface drives the same host, and the rest of our printable references sit in the free cheat sheet pack. The full parameter list for each cmdlet lives in Microsoft’s Hyper-V module reference.

More: Windows command and shortcut sheets

Hyper-V work rarely stays inside one module. Our PowerShell cheat sheet covers remoting, modules and the pipeline habits every cmdlet above leans on, and the Windows 11 keyboard shortcuts sheet saves clicks on the management workstation you run them from.

Keep reading

Claude Code Cheat Sheet: Commands, Shortcuts and Flags (PDF) AI Claude Code Cheat Sheet: Commands, Shortcuts and Flags (PDF) OpenAI Codex CLI Cheat Sheet: Shortcuts, Commands, Flags (PDF) AI OpenAI Codex CLI Cheat Sheet: Shortcuts, Commands, Flags (PDF) Linux and DevOps Cheat Sheets (Free PDF Pack) Cheat Sheets Linux and DevOps Cheat Sheets (Free PDF Pack) Install Grok Build on Windows 11 (Formerly Cursor) AI Install Grok Build on Windows 11 (Formerly Cursor) netsh Commands Cheat Sheet: Wi-Fi, Firewall, Port Proxy (PDF) Cheat Sheets netsh Commands Cheat Sheet: Wi-Fi, Firewall, Port Proxy (PDF) FastUnlock Windows 11 Lock-Screen Flaw: What Reduces Exposure Security FastUnlock Windows 11 Lock-Screen Flaw: What Reduces Exposure

Leave a Comment

Press ESC to close