Quantcast
Viewing all articles
Browse latest Browse all 228332

Re: Listing the virtual center for a given host

Greetings-

 

I see.  Looks like that property on the VMHostImpl object (returned from Get-VMHost) has not always been there.  I was checking against an environment that has the vSphere 5.1 API.  I saw, like you pointed out, that these other properties were not present when testing against a v5.0 API environment.

 

So, yes, like you said -- the ".Client.ServiceUrl" property of the View object for the host has a string that can be used to deduce the vCenter server name.  And, you can still access that property from the VMHostImpl object via the .ExtensionData property.  Something like:

 

Get-VMHost | select Name,
    @{n
="vCenter"; e={($_.ExtensionData.Client.ServiceUrl -replace"http[s]?://", "").Split("/")[0]}}

 

That do it?


Viewing all articles
Browse latest Browse all 228332

Trending Articles