Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Import-Module $env:SyncroModule
$Date=Get-Date; $Date=$Date.AddDays(-1).ToShortDateString()
$WBS=Get-WBSummary
$LastBackupResult=$WBS.LastBackupResultDetailedHR
$LastSuccessfulBackup=$WBS.LastSuccessfulBackupTime.ToShortDateString()
$LastBackup=$WBS.LastBackupTime
$Versions=$WBS.NumberOfVersions
$ErrorDesc=Get-WBJob -Previous 1; $ErrorDesc=$ErrorDesc.ErrorDescription
$SuccessfulBackupBody=@"
Date: $LastSuccessfulBackup
Backups Available: $Versions
"@
$FailedBackupBody=@"
Last Backup: Failed
Date: $LastBackup
Reason: $ErrorDesc
"@
$RecurringFailedBackupBody=@"
Last Backup: Failed
Date: $LastBackup
Last Successful Backup: $LastSuccessfulBackup
Reason: $ErrorDesc
"@
if($LastBackupResult -eq 0){
write-host "Backup Successful - $ENV:COMPUTERNAME - details $($SuccessfulBackupBody)"
}
elseif($LastBackupResult -ne 0 -or $LastSuccessfulBackup -lt $Date){
if($LastSuccessfulBackupTime -lt $Date){
Rmm-Alert -Category "windows_backup_failed" -Body $RecurringFailedBackupBody
}
else{
Rmm-Alert -Category "windows_backup_failed" -Body $FailedBackupBody
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment