Administer VMWare long enough and you will eventually lose a host. If you are using HA you may not notice until the phones start ringing some time later. At this point all the VMs are back on line on different hosts.
When Problem management/bosses get involved you will normally be asked “what VMs restarted?”
here is a handy script to quickly get that info.
Connect-VIServer -Server (your vcenter server)
$DaysToSearch = 1
$StartDate = (Get-Date).AddDays(-$DaysToSearch)
# will output a list of VMs (log entrys) to the screen.
Get-VIEvent -maxsamples 10000 -Start $StartDate -type warning | Where {$_.FullFormattedMessage -match "restarted"} |select CreatedTime,FullFormattedMessage |sort CreatedTime -Descending
# will output a list of VMs (log entrys) to a CSV file.
Get-VIEvent -maxsamples 10000 -Start $StartDate -type warning | Where {$_.FullFormattedMessage -match "restarted"} |select CreatedTime,FullFormattedMessage |sort CreatedTime -Descending | export-csv "C:\temp\HAedVMs.csv" -noTypeInformation
Note: Normally I would attach a screen shot of the results but I’m not going to power off a host to test the script. Believe me, I know it works.