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
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
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
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
Seems to be ok for me.
Can you show what you see in Tasks & Events?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Found it, I forgot the MaxSamples parameter.
I updated the code above, please try again.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Lucd.
Script is working As Expected.