I want to get my vms on a cluster with their datastores location.
how can i do this?
get-cluster "cluster" | get-vm * | select Name, etc....
Something like this ?
Get-Cluster | Get-VM |
Select Name,@{N="Datastore";E={[string]::Join(',', (Get-Datastore -VM $_ | %{$_.Name})}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thank luc. I dont quite understand what
E={[string]::Join(',', (Get-VM $_ | %{$_.Name})}} does. it gave me an output like this Name Datastore
------- -------------------
vm vm
but I was able to change it to
get-cluster cluster | get-vm vm* | Select NAme, @{N="Datastore";E={Get-Datastore -VM $_}}
which works now
thank you
That was indeed what it should have been. The join was there in case your VM is spread over multiple datastores? It's corrected now.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference