Try like this.
You might want to play with 1 minute, before and after, interval in the Get-VIEvent cmdlet.
Depending how busy your vCenter is, there might be a bigger delta between the snapshot timestamp and the event.
Update: fixed an issue with double User names.
This would happen when a snapshot was taken, then deleted and a new snapshot taken, within the time span of 2 minutes
$clusterName = 'MyCluster'
Get-Cluster -Name $clusterName | Get-VM | Get-Snapshot |
select Name,
Created,
@{N='VM';E={$_.VM.Name}},
@{N='VMHost';E={$_.VM.VMHost.Name}},
@{N='Cluster';E={$_.VM.VMHost.Parent.Name}},
@{N='Datacenter';E={
$p = Get-View -Id $_.VM.VMHost.Parent.ExtensionData.Parent -Property Name,Parent
while($p -and $p -isnot [VMware.Vim.Datacenter]){
$p = Get-View -Id $p.Parent -Property Name,Parent
}
if($p){
$p.Name
}
}},
@{N='SizeMB';E={[math]::Round($_.SizeMB,1)}},
@{N='SizeGB';E={[math]::Round($_.SizeGB,1)}},
@{N='User';E={
Get-VIEvent -Start $_.Created.AddMinutes(-1) -Finish $_.Created.AddMinutes(1) |
where{$_ -is [VMware.Vim.TaskEvent] -and $_.Info.DescriptionId -eq 'VirtualMachine.createSnapshot'} |
select -Last 1 -ExpandProperty UserName
}} |
Export-Csv snap-report.csv -NoTypeInformation -UseCulture