Retrospectively Check which VMs Migrated during HA Failover

Issue:

An ESXi server crashed invoking HA. I wanted to check which VMs had restarted and on what host so I could check they were functioning correctly.

 

Resolution:

Thanks to my colleague for the following PowerCLI script:

PowerCLI C:\> Connect-VIServer -Server {your_vcenter} -User {your_username} -Password {your_password}

PowerCLI C:\> $Date = Get-Date

PowerCLI C:\> $HAVMrestartold =5

PowerCLI C:\> Get-VIEvent -maxsamples 100000 -Start ($Date).AddDays(-$HAVMrestartold) -type warning | Where {$_.FullFormattedMessage -match "restarted"} |select CreatedTime,FullFormattedMessage |sort CreatedTime -Descending

 

Output:

CreatedTime         FullFormattedMessage
———–         ——————–
23/10/2017 01:27:19 vSphere HA restarted virtual machine win-sql-11 (xxxxxx) on host esx50.jordansphere.co.uk in cluster cl01
23/10/2017 01:26:38 vSphere HA restarted virtual machine win-sql-13 (xxxxxx) on host esx64.jordansphere.co.uk in cluster cl01
23/10/2017 01:25:02 vSphere HA restarted virtual machine ubuntu-02 (xxxxxx) on host esx48.jordansphere.co.uk in cluster cl01
23/10/2017 01:24:53 vSphere HA restarted virtual machine backend-SQL-01 (xxxxxxx) on host esx69.jordansphere.co.uk in cluster cl01
23/10/2017 01:24:53 vSphere HA restarted virtual machine backend-sql-02 (xxxxxxx) on host esx52.jordansphere.co.uk in cluster cl01
23/10/2017 01:24:53 vSphere HA restarted virtual machine mobile03 (xxxxxxx) on host esx70.jordansphere.co.uk in cluster cl01