Commanders:
Currently am managing 8 VCs (vSphere 5) through vSphere clinet. So searching one particular VM in all VCs is became horrible in this situation. Thinking of using PowerCLI to make this job easier. So I installed PowerCLI 5 and connected all my VCs.
I need a command line to search a VM, which returns the VC Name, Datacenter Name, Cluster Name and ESXi Hostname. I know that its a one line job and very easy for you guys to answer.
Thanks in advance!!!
Try something like this, it's not the fastest way, but it should give you all the values
Get-VM MyVM |
Select Name,@{N="ESX";E={$_.VMHost.Name}},
@{N="Cluster";E={Get-Cluster -VM $_ | Select -ExpandProperty Name}},
@{N="Datacenter";E={Get-Datacenter -VM $_ | Select -ExpandProperty Name}},
@{N="vCenter";E={$_.ExtensionData.Client.ServiceUrl.Split('/')[2]}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this, it's not the fastest way, but it should give you all the values
Get-VM MyVM |
Select Name,@{N="ESX";E={$_.VMHost.Name}},
@{N="Cluster";E={Get-Cluster -VM $_ | Select -ExpandProperty Name}},
@{N="Datacenter";E={Get-Datacenter -VM $_ | Select -ExpandProperty Name}},
@{N="vCenter";E={$_.ExtensionData.Client.ServiceUrl.Split('/')[2]}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You saved me from big trouble. I owe you zillion bucks!!!