Hi All,
We've been running this script for quite sometime and it has worked flawlessly, so i figured i'd leave it here to share. I'm sure the meat of the script came from this community but we've made a few tweaks.
We run it as a daily task and email the results to our team mailbox.
Hope you enjoy!
remove-item "C:\scripts\SnapshotIssues.txt"
$snapshotissues = "C:\scripts\SnapshotIssues.txt"
#get-vmhost | Where { ($_.extensiondata.configissue | Where { $_.FullFormattedMessage -eq "Virtual machine disks consolidation is needed." })}| Add-Content $snapshotissues
$StuckSnapshot = Get-VM | Where-Object {$_.Extensiondata.Runtime.ConsolidationNeeded}
Add-Content $snapshotissues $StuckSnapshot -Confirm:$false
Send-MailMessage -smtp "mysmtp.mydomain.com" -To "me@me.com" -Subject "Stuck Snapshots" -From "vCenter@domain.com" -Attachments $snapshotissues
Disconnect-VIServer -Confirm:$false