VMware Cloud Community
KevinLeek
Contributor
Contributor

Multiple vCenters connected to PowerCLI - how to tell which one

Maybe there is a simple answer but I haven't found it yet.

If I am connected to multiple vCenters then look for and find an object (VM, host, etc) how can I tell which vCenter hosted the object PowerCLI found? You can .Parent all the way up to Datacenter object but I did not see where the DC object would help you determine the vCenter.

Thank you,

Kevin

0 Kudos
3 Replies
LucD
Leadership
Leadership

These objects all have a link to the vCenter they belong to via the Client property.
For example

Get-VM |
Select Name,@{N='vCenter';E={([uri]$_.Client.ServiceUrl).Host}}

  


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

KevinLeek
Contributor
Contributor

I had to include ExtensionData ( $_.ExtensionData.Client.ServiceUrl ) but that got me there.

Thank you,

Kevin

0 Kudos
LucD
Leadership
Leadership

Correct, I forgot the ExtensionData part.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference