Created
December 1, 2017 16:11
-
-
Save theinventor/c50993f73f3185223a9dbce7c6439370 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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