How can I see when a VM reverted to a snapshot in PowerCLI?

Problem:

How can I see when a VM reverted to a snapshot in PowerCLI?

Solution:

$start = (Get-Date).AddDays(-120)
$fileName = "c:\temp\NameOfVM.csv"
$entity = Get-VM -Name NameOfVM
$GetRevert = Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) | where{$_ -is [VMware.Vim.EventEx] -and $_.EventTypeId -eq 'com.vmware.vc.vm.VmStateRevertedToSnapshot'} | Select CreatedTime,UserName,ObjectName, @{N='SnapshotName';E={($_.Arguments | where{$_.Key -eq 'snapshotName'}).Value}}
$GetRevert | Export-Csv -Path $fileName -NoTypeInformation -UseCulture 

Leave a Reply

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