VMware PowerCLI Discover VMs Restarted by VMware HA (Host Failure)

VMware

VMware HA (High Availability) is a great feature, but if the failure occurs when you are not watching it you may well need to know what was affected. You can use VMware PowerCLI to query vCenter for the VMs that have been affected by a host failure causing an HA restart event.

I’m assuming that you have VMware PowerCLI installed, so will just cover the steps to retrieve the information.

Firstly connect to vCenter with:

Connect-VIServer [vCenter Name]

Once connected, now run the following to obtain a list of all the VMs that were restarted.

Get-VIEvent -MaxSamples 100000 -Start (Get-Date).AddDays(-1) -Type Warning | Where {$_.FullFormattedMessage -match “restarted”} |select CreatedTime,FullFormattedMessage | sort CreatedTime –Descending

The above will obtain a list of all the VMs that were restarted in the last day (24 hours), you can adjust the figure within the “AddDays(-1)” function to retrieve earlier events if required.

Leave a Reply

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