Inventory Hyper-V VMs
Documentation: Microsoft Learn
List Hyper-V guests with Get-VM and report state, CPU usage, assigned memory in bytes, and status for each virtual machine.
The script
Script reader
Inspect before you run
Inspect the script below. It does not run in this browser.
Inspection only — no command has run.
Show reference output
Inspect this example’s structure
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Get-VM | Select-Object Name,State,CPUUsage,MemoryAssigned,Status- Stage 1Get-VM
Positional values or no named parameters - Stage 2Select-Object
Positional values or no named parameters
How it works
Get-VM returns the guests registered on the local host, and the projection keeps the name with State, the CPUUsage percentage, MemoryAssigned in bytes, and the Status string that surfaces conditions such as a degraded configuration.
Adapting it
Pass -ComputerName with a list of host names to gather several hosts into one table, and divide MemoryAssigned by 1GB so the column can be read without counting digits.
Requirements
Hyper-V PowerShell module and membership in Hyper-V Administrators.
If the result is unexpected
The Hyper-V VM list is empty or belongs to the wrong host.
The session may be querying the local machine or lack the module, role or remote access required.
- Confirm the Hyper-V host parameter and query a known VM under the intended identity.
Validate the result
The output names the queried host and includes the known VM.
Keep the check reliable
Keep host context explicit in multi-host inventory.