The essentials
Quick reference
One focused task per row. Jump to the related section for complete, working examples.
| Use | Syntax | Examples |
|---|---|---|
| List virtual machines | Get-VM | Sort-Object Name | View examples |
| Inspect one VM | Get-VM -Name 'App-Test-01' |
Format-List Name, VMId, State, Status, Generation, Version, Path | View examples |
| Inspect host defaults | Get-VMHost |
Format-List ComputerName, VirtualMachinePath, VirtualHardDiskPath, LogicalProcessorCount | View examples |
| Inspect VM memory | Get-VMMemory -VMName 'App-Test-01' | View examples |
| Inspect virtual processors | Get-VMProcessor -VMName 'App-Test-01' | View examples |
| Inspect network adapters | Get-VMNetworkAdapter -VMName 'App-Test-01' |
Select-Object Name, SwitchName, MacAddress, Status, IPAddresses | View examples |
| List virtual switches | Get-VMSwitch |
Select-Object Name, SwitchType, NetAdapterInterfaceDescription | View examples |
| Preview VM creation | New-VM -Name 'App-Test-01' -Generation 2 `
-MemoryStartupBytes 4GB -NoVHD -SwitchName `
'Lab-Switch' -WhatIf | View examples |
| Preview dynamic memory | Set-VMMemory -VMName 'App-Test-01' -DynamicMemoryEnabled `
$true -MinimumBytes 2GB -StartupBytes 4GB `
-MaximumBytes 8GB -WhatIf | View examples |
| Start a VM | Start-VM -Name 'App-Test-01' -WhatIf | View examples |
| Request guest shutdown | Stop-VM -Name 'App-Test-01' -Shutdown -WhatIf | View examples |
| List checkpoints | Get-VMCheckpoint -VMName 'App-Test-01' |
Sort-Object CreationTime | View examples |
| Create named checkpoint | Checkpoint-VM -Name 'App-Test-01' -SnapshotName `
'Before-App-Upgrade' -WhatIf | View examples |
| Preview checkpoint restore | Restore-VMCheckpoint -VMName 'App-Test-01' -Name `
'Before-App-Upgrade' -WhatIf | View examples |
| Preview VM export | Export-VM -Name 'App-Test-01' -Path 'E:/VMExports' `
-WhatIf | View examples |
| Inspect an import plan | Compare-VM -Path `
'E:/VMExports/App-Test-01/Virtual Machines/VM-ID.vmcx' `
-Copy -GenerateNewId | View examples |
Hyper-V cmdlets control host resources and durable virtual-machine state, often across storage and network boundaries. Run administrative changes from an elevated session, resolve the exact host and VM before acting, preserve console or cluster access, and treat checkpoints as short-lived change controls rather than backups. Commands below use explicit names and preview state changes where the cmdlet supports WhatIf.
Step by step
Detailed examples
Resolve host and VM identity before every change
A display name is convenient but can be reused after deletion, while VMId identifies one registered VM. Confirm the target host, VMId, generation, configuration version, paths, state, and cluster ownership before mutation. Most Hyper-V administration requires elevation or delegated Hyper-V Administrators rights; remote or clustered changes need an out-of-band recovery path.
Get-VMHost | Select-Object ComputerName, VirtualMachinePath, VirtualHardDiskPath
Get-VM -Name 'App-Test-01' | Select-Object Name, VMId, State, Status, Generation, Version, Path Correlate compute, disks, and network configuration
A healthy VM object does not prove that memory pressure, disk placement, switch connectivity, or guest networking is correct. Inspect resource objects separately. IPAddresses are reported through integration services and can be empty or stale; validate connectivity from the intended network rather than treating them as authoritative inventory.
Get-VMMemory -VMName 'App-Test-01'
Get-VMProcessor -VMName 'App-Test-01'
Get-VMHardDiskDrive -VMName 'App-Test-01' | Select-Object ControllerType, ControllerNumber, ControllerLocation, Path
Get-VMNetworkAdapter -VMName 'App-Test-01' | Select-Object Name, SwitchName, MacAddress, Status, IPAddresses Create from an explicit resource and storage plan
Choose generation, boot model, storage paths, virtual switch, memory bounds, CPU count, firmware, and security requirements before creation. Generation cannot be changed later. Preview supported cmdlets, ensure every VHD path is backed up or disposable as appropriate, and verify the VM while it remains off before connecting installation media or a production network.
Get-VMSwitch | Select-Object Name, SwitchType, NetAdapterInterfaceDescription
New-VM -Name 'App-Test-01' -Generation 2 -MemoryStartupBytes 4GB -NoVHD -SwitchName 'Lab-Switch' -WhatIf
Set-VMMemory -VMName 'App-Test-01' -DynamicMemoryEnabled $true -MinimumBytes 2GB -StartupBytes 4GB -MaximumBytes 8GB -WhatIf Prefer guest-coordinated lifecycle operations
Starting a VM consumes host capacity. Stop-VM -Shutdown asks an integration service to shut down the guest cleanly and can fail if the service or guest is unresponsive. Stop-VM -TurnOff is equivalent to removing power and risks guest data corruption; use it only under an approved incident procedure. Recheck state and critical workloads after any transition.
Get-VM -Name 'App-Test-01' | Select-Object Name, State, Status, Uptime
Stop-VM -Name 'App-Test-01' -Shutdown -WhatIf
Get-VM -Name 'App-Test-01' | Select-Object Name, State, Status Use production checkpoints as temporary rollback aids
Production checkpoints request an application-consistent guest snapshot; ProductionOnly prevents silent fallback to a standard memory-state checkpoint. A checkpoint is not an independent backup, grows differencing disks, and restoring it discards later guest state. Replicated services such as domain controllers and databases require product-specific recovery guidance. Remove checkpoints only after validation and allow merges to finish.
Set-VM -Name 'App-Test-01' -CheckpointType ProductionOnly -WhatIf
Checkpoint-VM -Name 'App-Test-01' -SnapshotName 'Before-App-Upgrade' -WhatIf
Get-VMCheckpoint -VMName 'App-Test-01' | Select-Object Name, Id, CreationTime, CheckpointType Treat export and import as verified recovery workflows
An export can include configuration, virtual disks, and checkpoints, but it is not a substitute for application-aware backup policy. Confirm destination capacity and protection, wait for completion, inventory files, and test recovery on an isolated switch. Compare-VM reports incompatibilities before import; copy/import with a new ID when creating a distinct VM to avoid identity collisions.
Export-VM -Name 'App-Test-01' -Path 'E:\VMExports' -WhatIf
$report = Compare-VM -Path 'E:\VMExports\App-Test-01\Virtual Machines\VM-ID.vmcx' -Copy -GenerateNewId
$report.Incompatibilities | Select-Object Message, MessageId, Source Sources and further reading
References
Authoritative documentation used to verify and expand this cheat sheet.
Help us improve
Found a typo or missing example?
Tell us what would make this cheat sheet clearer, more complete, or more useful.



