Below script is used to find the users who created or deleted the VM in the past 7 days.

Note: If you want to know the count for longer period then change the value of AddDays.

For VM creation

Get-VIEvent -MaxSamples ([int]::MaxValue) -Start (Get-Date).AddDays(-30) |

where {$_.Gettype().Name -eq “VmCreatedEvent” -or $_.Gettype().Name -eq “VmBeingClonedEvent” -or $_.Gettype().Name -eq “VmBeingDeployedEvent”} |

%{“{0} created by {1}” -f $_.VM.Name,$_.UserName}

 For VM Deletion

Get-VIEvent -MaxSamples ([int]::MaxValue) -Start (Get-Date).AddDays(-7) | where {$_.Gettype().Name -eq “VmRemovedEvent”} |  %{“{0} created by {1}” -f $_.VM.Name,$_.UserName}

Posted in: Vmware.
Last Modified: January 12, 2017

Leave a reply