HA VM failover tracking

Another interesting question in the PowerCLI Community today.
David wanted to know if it was possible to track which VMs had been failed over to another ESXi host by HA.
With the Get-VIEventPlus function from my Get the vMotion/svMotion history post it is easy to get that informatiom from the Tasks and Events that are kept in the vCenter database.


But which event to look for ?

The Making Of

In the PowerCLI Community there are often questions on how track a specific type of event. The best source of information to start with is of course the VMware vSphere API Reference Documentation. Under the Data Object Types you’ll find most of the events that can occur in a vSphere environment.

But there are ways to make the search easier. In my Events – Part 7 : Working with extended events – Update Manager post I already provided a short script to produce a cross-reference of the available events in your vSphere environment.

This is an improved version of that script.

The resulting table looks something like this.


Important to remember here, there are 3 major categories of events: a regular Event, an EventEx and an ExtendedEvent. The hierarchy of these different object types looks like this.


Now that we have our events XRef, it’s a matter of doing a bit of searching. The Excel filtering options do wonders here. In this case it was obvious that the HA component produces a number of events that all seem to start with com.vmware.vc.HA. The one we were after had VmRestartedByHAEvent in the identifier. And the Description confirms that this was the event we were looking for.


We pass this EventTypeId with the EventType parameter to the Get-VIEventPlus function. This is explained in the description of the eventTypeId property on the EventFilterSpec object.

The script to get the specific events and produce a report is quite simple.

The result looks something like this.


Enjoy !


    Oskar Norén

    Hi Luc,

    Is it possible to retrieve the source host also?
    I’ve been looking through the tasks and events in vSphere Client and via PowerCLI, but I can’t really find anything to bind the events together.

    – Oskar


    how can I see the list of task snapshot failure on VM ?
    As seen in the ESX Task view panel (not Event view).
    I do not want to have the list of event but list task thougt PowerCLI.
    thank you

    Andreas Peetz

    Hi Luc,

    a while ago I published a handy little script that also automates this task and lists successful and also failed(!) HA restarts: See http://www.v-front.de/2012/06/how-to-list-vsphere-50-ha-restarts-with.html

    – Andreas


      Hi Andreas, nice script, and very useful.
      I used the VMTN question to explain a bit how one can find out which events to look for. And to push my Get-VIEventPlus function of course 😉

Leave a Reply

Your email address will not be published. Required fields are marked *


2 × 1 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.