Hyper-V How To: List VMs using Script


Some friends here on the Hyper-V team shared a PowerShell 2.0 script for getting a list of VMs:



# List VMs


$vmList = gwmi -namespace root\virtualization Msvm_ComputerSystem |`
    where{$_.Name -ne $env:COMPUTERNAME}


$vmList | select ElementName,Name,EnabledState,StatusDescriptions | format-list







For more info on how to use PS cmdlets see: http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/index.mspx


See also James O’Neil’s New and improved PowerShell Library for Hyper-V. Now with more functions and… documentation!


For all 35 sample Hyper-V PS1 scripts in a zipfile, go to: Hyper-V PowerShell Example Scripts.zip-download

Comments (0)