VMware Cloud Community
Sivaramsharmar
Enthusiast
Enthusiast
Jump to solution

Snapshot Revert Events

Hi All,

Does any one has powercli script to get the VM Snapshot revert (Event) Details past 2 days.

Similiar Output like below:

VM Name                User Name(Who Reverted)               Date (When They Reverted)

--------------                   ---------------------------------                    -------------------------------

VM1                                        User1                                                  5/3/2018

VM2                                        User2                                                  4/3/2018

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

$start = (Get-Date).AddDays(-2)

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}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

$start = (Get-Date).AddDays(-2)

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}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Sivaramsharmar
Enthusiast
Enthusiast
Jump to solution

Hi Lucd,

I tried your script, but the output is null.

But 2 days back there are couple of VMs for which Snapshot got reverted. I can able to see it in Tasks & Events.

I am using below PowerCLI Version:

PowerCLI Version

----------------

   VMware PowerCLI 6.5 Release 1 build 4624819

---------------

Component Versions

---------------

   VMware Cis Core PowerCLI Component 6.5 build 4624453

   VMware VimAutomation Core PowerCLI Component 6.5 build 4624450

   VMWare ImageBuilder PowerCLI Component 6.5 build 4561891

   VMWare AutoDeploy PowerCLI Component 6.5 build 4561891

   VMware HA PowerCLI Component 6.0 build 4525225

   VMware Licensing PowerCLI Component 6.5 build 4624822

   VMware Storage PowerCLI Component 6.5 build 4624820

   VMware Vds PowerCLI Component 6.5 build 4624695

vCenter: 6.0 2776510

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Seems to be ok for me.

Can you show what you see in Tasks & Events?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Sivaramsharmar
Enthusiast
Enthusiast
Jump to solution

I can able to see the Events in vCenter Taks & Events GUI.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Found it, I forgot the MaxSamples parameter.

I updated the code above, please try again.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Sivaramsharmar
Enthusiast
Enthusiast
Jump to solution

Thanks Lucd.

Script is working As Expected.

Reply
0 Kudos