#Troubleshooting snapshot checks #bwuch 2011/05/11 #Email blog [@] enterpriseadmins.org # Set the warning threshold for snapshots in days old $SnapshotAge = 0 #default is 14days #These are built-in variables in vCheck $date = get-date $VM = Get-VM | Sort Name #This is around line 816 in vCheck 5.00 #The line that looks like the following comment was replace with the included code block #$Snapshots = @($VM | Get-Snapshot | Where {$_.Created -lt (($Date).AddDays(-$SnapshotAge))} | Get-SnapshotSummary) $snapshots = @() $vm | Get-Snapshot | Where {$_.Created -lt (($Date).AddDays(-$SnapshotAge))} | %{ $objSnap = $_ $detail = "" | select VM, SnapshotName, DaysOld, Creator, SizeMB, Created, Description $detail.VM = $_.VM.name $detail.SnapshotName = $_.Name $detail.DaysOld = ((Get-Date) - $_.Created).Days $detail.Creator = ($_.VM |get-vievent| where {$_.FullFormattedMessage -eq "Task: Create virtual machine snapshot" -AND $_.CreatedTime -match $objSnap.Created}).UserName $detail.sizeMB = $_.SizeMB $detail.Created = $_.Created $detail.Description = $_.Description $snapshots += $detail } $snapshots #If this works correctly, we can remove lines 578 through 665 in vCheck 5.00 -- the snapshot functions