HI All,
Over my career I have noticed that Veeam has an issue with snapshots deletion, sometimes snapshots stuck on virtual machines and staying on for a while, which mean that accumulation of snapshots is created, even I have seen some snapshots that stuck for more than an year.
Moreover, some jobs would failed if there are many snapshots on virtual machines, therefore I have prepare a Powershell script that recognize only “Veeam” snapshots which existing more than 7 days and then deleting them, sending you email as we ll.
Connect-VIServer 'vCenter'
$date = Get-Date -date $(Get-Date).AddDays(-7)
$body = get-vm -Location "Cluster-Name" | Get-Snapshot | where-object { $_.Created -lt $date -and $_.Name -like "veeam*"} | select vm, created
$Emailtext= "`r`n The following snapshot were stuck on those VM's, all of them have been deleted successfully"
function SendEmail
{
$from
Send-MailMessage -From 'xxx' -To 'xxx' -Subject "Veeam Snapshot has stuck on VM's" -Body ($Body, $Emailtext | Out-String) -SmtpServer 'xxx'
}
function DeleteSnap
{
Get-Snapshot $body.VM| Remove-Snapshot -confirm:$false
}
if ($body.VM.NAME -ne $Null ) {DeleteSnap ; SendEmail}