This is really good, thanks! Now I just need to tie this in with what I'm currently trying to do, which goes like this:
foreach ($vm in (Get-VMHost -Name $hostname | Get-VM)) {Get-VIEvent -Entity $vm | Export-Csv -Path C:\foo.csv -Force -Append }
So far I've integrated your suggestion as follows, but it only returns the timestamps:
foreach ($vm in (Get-VMHost -Name $hostname | Get-VM)) {Get-VIEvent -Entity $vm | Select @{N='CreatedTime';E={$_.CreatedTime.ToString('HH:mm:ss')}}}
What I need is the VM Name, and (associated by ChainId I think) the Task: Remove snapshot and linked "Virtual machine foobar disks consolidated successfully" from FullFormattedMessages.
I can live with the output as in the first one-liner and grind up the data in Excel but I'm always open to a better way.