PowerCLI: One-Liner to get VMs, Clusters, ESX Hosts and Datastores
November 17, 2009 5 Comments
With the one-liner below, you’re able to create an overview of your VM’s, Clusters, ESX Hosts and Datastores.
Get-VM | Select Name, @{N="Cluster";E={Get-Cluster -VM $_}}, ` @{N="ESX Host";E={Get-VMHost -VM $_}}, ` @{N="Datastore";E={Get-Datastore -VM $_}}
The following output will be generated:
If you add an extra line with the export-csv cmdlet, you can export the output to a CSV file.
Get-VM | Select Name, @{N="Cluster";E={Get-Cluster -VM $_}}, ` @{N="ESX Host";E={Get-VMHost -VM $_}}, ` @{N="Datastore";E={Get-Datastore -VM $_}} | ` Export-Csv -NoTypeInformation C:\Scripts\VM_CLuster_Host_Datastore.csv
If you want, you can import the CSV file into Excel. Excel has some basic filtering options, so you’re able to filter on ESX Host, Cluster etc.





Pingback: uberVU - social comments
Hi,
Thanks a lot for this script. It will save me a lot of time to make a report of all my vms and their location.
Thanks for sharing your job with us.
God Bless You.
Pingback: powerCLI to get VM, cluster, Host, and datastore « Cyclops' Blog
This is great script. It helped me a lot.
Additionally can you suggest how to get Total and free space details against each datastore.
Thanks!
how to pass two vm-guest name in single powerCLI to remove from disk.