Cry about...
Windows Hyper-V-Server
How to list virtual machines using PowerShell
To list the virtual machines on a hyper-v-server use
PowerShell cmdlet Get-VM
.
(Get-VM is provided by the module Hyper-V which is pre-installed on
Windows Hyper-V-Server.)
Get-VM on its own will list the virtual machines on the server:
PS C:\Users\Administrator> get-vm
Name State CPUUsage(%) MemoryAssigned(M) Uptime Status
---- ----- ----------- ----------------- ------ ------
New Virtual Machine Off 0 0 00:00:00 Operating n...
New Virtual Machine Off 0 0 00:00:00 Operatng n...
PS C:\Users\Administrator>
Obviously your output may be different from mine.
If you have multiple virtual machines and only want to list a specific one then use the parameter -name, thus:
PS C:\Users\Administrator> get-vm -name "New Virtual Machine"
Name State CPUUsage(%) MemoryAssigned(M) Uptime Status
---- ----- ----------- ----------------- ------ ------
New Virtual Machine Off 0 0 00:00:00 Operating n...
New Virtual Machine Off 0 0 00:00:00 Operating n...
PS C:\Users\Administrator>
Needless to say you will get an error if the named virtual machine (or machines) do not exist.
To query a remote machine use:
get-vm -ComputerName name
where "name" is the name of the remote computer (or its IP address).
To list just those virtual machines which are running use:
get-vm | Where-Object {$_.State -eq 'Running'}
About the author: Brian Cryer is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.