Home > PowerCLI, vSphere > List HA Runtime States with PowerCLI

List HA Runtime States with PowerCLI

The HA Agent on vSphere 4.x Hosts can be in several states:

– uninitialized
– initialized
– running
– error
– agentShutdown
– nodeFailed

If you have HA Enabled on your cluster, all states except running are basically not good and requires investigation.

These states can be fetched, but to my knowledge there is no easy cmdlet available to do so… so we’ll have to dig in the SDK.

The properties are exposed through a cluster object (makes sense since HA can only be enabled at cluster level and not at host level).

Get-View -ViewType "ClusterComputeResource" -Property "Name"

This gives you all Cluster objects in your environment (ViewType –> ClusterComputeResource).  We only fetch the “Name” property because we don’t need all the other ones and it speeds up the cmdlet big time.

Next, we need to call the RetrieveDasAdvancedRuntimeInfo method on each Cluster object.  That returns yet another object and we need to look into the DasHostInfo.HostDasState property.

Get-View -ViewType "ClusterComputeResource" -Property "Name" | Foreach-Object {$_.RetrieveDasAdvancedRuntimeInfo().DasHostInfo.HostDasState}

This gives us something like this:

image

Now it’s just a matter of piping this through a Format-Table to get a nice overview and we’re set!

Get-View -ViewType "ClusterComputeResource" -Property "Name" | Foreach-Object {$_.RetrieveDasAdvancedRuntimeInfo().DasHostInfo.HostDasState} | Format-Table -Property "Name", "RuntimeState"

Et voila, just the info we need!

image

Advertisements
Categories: PowerCLI, vSphere
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: