Hi All,
I was trying to pull the report from the snapshot report but its returns empty but in RV tools report shows that there is a snapshot for the VM exists.
Amy help will be much appreciated on this. I am using PowerCLI 6.0 Release 1 build 2548067.
Get-VIEvent -MaxSamples ([int]::MaxValue) |
Where-Object {$_.FullFormattedMessage -imatch 'Task: Create virtual machine snapshot'} |
Select CreatedTime,Name,UserName,@{N='VM';E={Get-View $_.VM.VM | Select -ExpandProperty Name}} | Export-Csv report.csv -NoTypeInformation -UseCulture
Thanks
vmk2014
I'm lost.
You should be seeing the creation of those snapshots (at least the ones created during the last 30 days) with the code from the beginning.
You are sure you are looking for the report.csv in the correct folder?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi vmk2014,
Have you tried running the query with a match on regex string rather than the full text? Like so:
Get-VIEvent -Start (Get-Date).AddDays(-7) -Finish (Get-Date) | Where {$_.FullFormattedMessage -match "Create.*snapshot"}
If that returns the latest snapshots, then the script I originally responded with would look like this:
$snapshotlist = Get-VM|Get-Snapshot
$snapshotout = @()
ForEach($snapshot in $snapshotlist){
$start = $start = ($snapshot.Created).AddMinutes(-1)
$finish = ($snapshot.Created).AddMinutes(1)
$event = Get-VIEvent -Start $start -Finish $finish -Entity $snapshot.VM | Where {$_.FullFormattedMessage -match "Create.*snapshot"}
$snapshotout += New-Object PSObject -Property @{vmname = $snapshot.VM.Name; created = $snapshot.created; username = $event.UserName}
}
$snapshotout|Export-Csv c:\SnapshotReport.csv -NoTypeInformation -UseCulture
LucD,
Will check and let you know.
Thanks
vmk2014
Hi Kwhornics,
Will check and let you know.
Thanks
vmk2014
