PowerShell Genie

Hyper-V module: setup and commands

Module 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Inspect VMs with Get-VM, review checkpoints and virtual switches, and distinguish configured state from replication and runtime health.

Getting it

Comes with the Hyper-V role or the management tools feature. Enable it with Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell.

Examples

1PS> Get-VM
Show reference output
1 Name State CPUUsage(%) MemoryAssigned(M) Uptime
2 ---- ----- ----------- ----------------- ------
3 WEB01 Running 4 4096 2.03:14:08
4 DEV01 Off 0 0 00:00:00
1PS> Get-VMSnapshot -VMName App01
Show reference output
1 Name State CPUUsage(%) MemoryAssigned(M) Uptime
2 ---- ----- ----------- ----------------- ------
3 WEB01 Running 4 4096 2.03:14:08
4 DEV01 Off 0 0 00:00:00

What it is for

Use it for host-side inventory, checkpoint hygiene, and replication health. It is also how a guest build gets scripted end to end, since New-VM and its companions expose every setting the console does.

Typical tasks

  • Inventory VMs with state and assigned memory
  • Find checkpoints older than a threshold
  • Audit replication health for each VM
  • List virtual switches and their type
  • Check dynamic memory configuration
  • Report which VMs run on which host

Check the installed version

1PS> Get-Module -ListAvailable Hyper-V | Select-Object Name, Version, Path
2PS> Get-Command -Module Hyper-V

Compare the module path and version with the session used by your scheduled task or automation account. Use it for host-side inventory, checkpoint hygiene, and replication health. It is also how a guest build gets scripted end to end, since New-VM and its companions expose every setting the console does.

Primary documentation

Windows services and processes documentation

Continue
Genie guideHyper-V module: setup and commands

Inspect VMs with Get-VM, review checkpoints and virtual switches, and distinguish configured state from replication and runtime health.