VMware Cloud Community
sfresher
Contributor
Contributor

How to check if a host is connected to any vCenter?

I was trying to use PowerCLI to check if a host is connected to any vCenter?  Checked all Get-VMHost related properties, but couldn't find it.  Is it possible?

0 Kudos
3 Replies
LucD
Leadership
Leadership

Did you try the State and ConnectionState properties ?

Get-VMHost | Select Name, State, ConnectionState

Both are the same, but State will become obsolete in a future PowerCLI build.


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

0 Kudos
loneragang
Contributor
Contributor

If you are connecting directly to the esx host using powercli and looking for the vCenter that is it connected to you could use

get-vmhost | get-view | select {$_.summary.managementserverip}

Unfortunately this field only exists in ESX 4.x, I can't find anything equivalent for esx 3.x

0 Kudos
AlbertWT
Virtuoso
Virtuoso

Hi,

If you are using the PowerCLI, I assume that you are connecting to one VCenter server right ?

so may I know what's the goal of this question ?

I usually begin my Powershell with

Connect-VIServer server1 -User "BLah1" -Password "password123"
and by running this query get-vmhost | get-view | select {$_.summary.managementserverip}
I get the IP address of server1 repeated by the number of ESXi hosts in the VCenter.
/* Please feel free to provide any comments or input you may have. */
0 Kudos