Hi All
I have a basic requirement of listing all VM's on each Virtualcentre with their host name and cluster.
And this is a way of doing it;
Get-VM | Select Name, @{N="Cluster";E={Get-Cluster -VM $_}}, @{N="ESX Host";E={Get-VMHost -VM $_}}
But this seems very slow and I guess I'm going around the loops each time to get basic information that I assume I could get in one go as a property of the machine ?
If any of you have a more efficient way of doing it I'd appreciate it. To be honest I only really need the host name as I can map that to a cluster name. But even;
Get-VM | Select Name, @{N="ESX Host";E={Get-VMHost -VM $_}}
is slow (and presumably inefficient)...
Appologies for the stupid question in advance!
Many thanks
Simon
This should be faster
Get-VM | Select Name,@{N="Host";E={$_.Host.Name}}
PS: there are no stupid questions 🙂
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This should be faster
Get-VM | Select Name,@{N="Host";E={$_.Host.Name}}
PS: there are no stupid questions 🙂
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes thats much better - I'll get my head around this stuff one day!
Many thanks - brilliantly helpful as always
Thanks, I nice trick, beside the Get-Member cmdlet, to explore objects returned by PowerCLI is this
Get-VM | Format-Custom -Depth 2
With the Depth parameter you define how deep you want to go in the nested objects.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
To get the clustername as well you can do:
Get-VM | Select Name,@{N="Host";E={$_.Host.Name}},@{N="Cluster";E={$_.Host.Parent}}
Regards, Robert