Select Page

Required Files: None


Monitor ShadowProtect jobs and alert if there is an issue


 

Import-Module $env:SyncroModule
 
try{
    $ShadowProtectLog = Get-EventLog -logname Application | Where-Object {(Get-Date $_.TimeWritten) -gt ((Get-Date).AddHours(-24))}
} catch {
    $ScriptError = "Query Failed: $($_.Exception.Message)"
    #write-error will write an error log like write-host and continue
    write-error $ScriptError
}
foreach($logentry in $ShadowProtectLog){
    if($logentry.Message -match "Warning"){ $ShadowProtectStatus += "Backup at $($logentry.TimeGenerated) has a warning"}
    if($logentry.Message -match "Error"){ $ShadowProtectStatus += "Backup at $($logentry.TimeGenerated) has an error"}
    if($logentry.Message -match "Failed"){ $ShadowProtectStatus += "Backup at $($logentry.TimeGenerated) has failed"}
}
if (!$ShadowProtectStatus) { $ShadowProtectStatus = "Healthy" }
if (!$ScriptError) { $ScriptError = "Healthy" }
 
if (!$ShadowProtectStatus) 
    { 
        Rmm-Alert -Category "shadowprotect_job_error" -Body "ShadowProtect Job Error: $ShadowProtectStatus" 
    }