Powershell: List all clusters, their hosts and VMs

16 Jul

Okay I know it bad practise to have nested pipes, which means its better to refractor it, but sometimes you just want a quick and dirty throw away real world one-liner to get what you want quickly.

Anyhow, if you need to get a list of all clusters, which hosts they have and which VMs each hosts has (note that with DSR this is not static), you can use this. It outputs per line “clusterhostVM”, you just need to open the text file and copy and paste to Excel or any spreadsheet and they will go nicely into each column.

get-cluster | % { $c=$_ ; get-vmhost -location $c | % { $h=$_ ; get-vm -location $h | % { "$c`t$h`t$_" | out-file c:\temp\output.txt -append } } }

Leave a comment

Posted by on July 16, 2013 in powershell, Scripts, vmware


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: