VMware Cloud Community
sysengx
Contributor
Contributor

Get Cluster Name/ID from ESXi CLI?

I know how to get the list of hosts in a cluster using PowerCLI connecting to vCenter, but is there a way to get the name or ID of the cluster a host is in from the ESXi (5.5) command line? Thanks.

Reply
0 Kudos
3 Replies
bspagna89
Hot Shot
Hot Shot

You can try using the following command :

Get-VMhost |ft name,parent

That should give you the ESX host + parent object which in this case is the cluster.

New blog - https://virtualizeme.org/
Reply
0 Kudos
sysengx
Contributor
Contributor

I'm looking for something that uses the ESXi CLI, not PowerCLI.

Reply
0 Kudos
NavalgundRaj
Enthusiast
Enthusiast

Hi,

Right now am not infront of the vmlab or prod environ,

So below PS would be of a help please try out and let me know

Function Get-ClusterNameFromVMName{

param(

[string[]]$VMName,

[hashtable]$VmsToHostHash,

[hashtable]$HostToClusterHash

)

return $HostToClusterHash[$vmsToHostHash[$VMname]]

}

Thenget cluster name by typing:
Get-ClusterNameFromVM -VMName ‘SomeVMname’ -VmsToHostHash $VmsToHostHash -HostToClusterHash $HostToClusterHash

Note: If you found this correct or answer useful please consider the use of the Correct buttons to award points. Regards Basavaraj.R Navalgund
Reply
0 Kudos