Hey guys - I found this script which is running fine except that it doesn't seem to show the users who created the snapshots unless they were created by veeam - running 5.5 u3
Any thoughts about how to extract the user who created the snapshot?
Thanks!
#Script for getting VMs and their snapshot information from ESXi Server/vCenter 4+
#original by virtualcurtis (http://virtualcurtis.wordpress.com)
#modified by Christian
# - disabled "has a snapshot"-Output
# - modified for german ESXi 4.1
# - added snapshot name and description
# - increased MaxSamples value from 1000 to 5000
$myVMs = Get-VM
$VMsWithSnaps = @()
foreach ($vm in $myVMs) {
$vmView = $vm | Get-View
if ($vmView.snapshot -ne $null) {
#Write-Host "VM $vm has a snapshot"
$SnapshotEvents = Get-VIEvent -Entity $vm -type info -MaxSamples 5000 | Where {
$_.FullFormattedMessage.contains("Get a snapshot")}
try {
$user = $SnapshotEvents[0].UserName
$time = $SnapshotEvents[0].CreatedTime
} catch [System.Exception] {
$user = $SnapshotEvents.UserName
$time = $SnapshotEvents.CreatedTime
}
#Get snapshot information
$SnapshotInfo = Get-Snapshot $vm
$VMInfo = "" | Select "VM","Name","Description","CreationDate","User"
$VMInfo."VM" = $vm.Name
$VMInfo."Name" = $SnapshotInfo.Name
$VMInfo."Description" = $SnapshotInfo.Description
$VMInfo."CreationDate" = $time
$VMInfo."User" = $user
$VMsWithSnaps += $VMInfo
}
}
$VMsWithSnaps | Sort CreationDate