Dell AppAssure does not alert on Exchange log trunction failures out of the box. This script uses their cmdlets to determine if it has been more than two days since the last Exchange database log truncation. It will provide both console output and will email specified recipients. The emailed report is html formated with color coding for passes (green) and failures (red) for easy scrolling. The email subject will either alert to specific failures or specify that all servers passed the truncation check. 

 

JavaScript
Edit|Remove
<# 
 .SYNOPSIS  
This script is meant to report on the truncation backups of an Exchange environment with AppAssure 
 
 .DESCRIPTION 
Checks the last truncated backup and alerts if it is over 2 days ago. 
 
 .EXAMPLE 
.\Check-Truncation.ps1 
Does a basic script run through 
 
 .NOTES 
Written By: Paul DiMarino 
 
 .CHANGE LOG 
v1.00    - 2016/07/06    - First version started 
#> 
 
#............................................ 
#Loads AppAssure Shell 
#............................................ 
 
Import-Module AppAssurePowerShellModule 
 
#............................................ 
# Mail Server Variables 
#............................................ 
 
$server = "{your smtp relay" 
$sender = "Your Sending Address <{address@domain.com}>" 
$recipient = "{address@domain.com}" 
$alertmessagebody = $null 
$alertmessagesubject = $null 
 
#............................................ 
# Script Variables 
#............................................ 
 
$compareDate = (Get-Date).AddDays(-2) 
$GlobalFailure = $null 
$ReportDate = Get-Date -Format F 
$AppAssureServer = $env:computername 
 
#............................................ 
# Script Begins Processing Protected Servers 
#............................................ 
 
Write-Host "--------------- Retrieving Protected Servers ---------------`n" -ForegroundColor Cyan 
$servers = (get-protectedservers).displayname 
Write-Host "$($servers.count) Protected Servers found in this AppAssure instance...`n" -ForegroundColor Green 
 
# Sets Email and File Information 
$BackupIntro = "<p><strong>AppAssure Protected Exchange Servers</strong> Component Alert Summary:</p>" 
$BackupReport = @() 
 
ForEach ($server in $servers) 
    { 
        Write-Host "`n--------------- Processing Backup State of $($server) ---------------" -ForegroundColor Cyan 
         
        $LastGood = (Get-Completedjobs -ProtectedServer $server | where {($_.Summary -like "*with log truncation*" -AND $_.Status -eq "Succeeded")} | select-object EndTime | sort-object EndTime -Descending | select-object -First 1).EndTime 
        $Alert = Get-Completedjobs -ProtectedServer $server | where {($_.Summary -like "*with log truncation*" -AND $_.Status -eq "Succeeded")} | Where-Object {$_.EndTime -ge $compareDate} 
        If (!($Alert)) 
            { 
                $BackupStatus = "FAIL" 
                If ($GlobalFailure) 
                    { 
                        $GlobalFailure += ", "+$server 
                    } 
                Else 
                    { 
                        $GlobalFailure = $server 
                    } 
            } 
        Else 
            { 
                $BackupStatus = "PASS" 
            } 
 
        $BackupReportObj = New-Object PSObject 
        $BackupReportObj | Add-Member NoteProperty -Name "Server" -Value $server 
        $BackupReportObj | Add-Member NoteProperty -Name "Backup Status" -Value $BackupStatus 
        $BackupReportObj | Add-Member NoteProperty -Name "Last Truncation" -Value $LastGood 
        $BackupReport += $BackupReportObj 
         
        ####Begin Backup Report Table HTML### 
        $BackupReportHTML = $null 
 
        #Begin Table Header 
        $htmltableheader = "<p> 
                    <table> 
                    <tr> 
                    <th>Server</th> 
                    <th>Backup Status</th> 
                    <th>Last Truncation</th> 
                    </tr>"             
        $BackupReportHTML += $htmltableheader 
        #End Table Header 
 
        #Begin Table Rows 
        ForEach ($row in $BackupReport) 
            { 
                $htmltablerow = "<tr>" 
                $htmltablerow = $htmltablerow + "<td><strong>$($row."Server")</strong></td>" 
 
                #Fail if status is FAIL 
                switch ($($row."Backup Status")) 
                { 
                    "PASS" { $htmltablerow = $htmltablerow + "<td class=""pass"">$($row."Backup Status")</td>" } 
                    default { $htmltablerow = $htmltablerow + "<td class=""fail"">$($row."Backup Status")</td>" } 
                } 
     
                $htmltablerow = $htmltablerow + "<td>$($row."Last Truncation")</td>" 
 
                $htmltablerow = $htmltablerow + "</tr>" 
                $BackupReportHTML += $htmltablerow 
            } 
        $BackupReportHTML += "</table> </p>" 
    } 
 
#............................................ 
# Output report to the console 
#............................................ 
Write-Host "`n ---- Protected Server Backup Report ---- " 
$BackupReport | ft 
 
#............................................ 
# Output the report to HTML  
#............................................ 
$AppAssureReportHTML = $BackupIntro + $BackupReportHTML 
$AlertMessageBody += $AppAssureReportHTML 
$htmlhead="<html> 
             
            <body> 
            <h3 align=""center"">AppAssure Protected Exchange Server Report</h3> 
            <p>AppAssure Backup State as of $reportdate</p>" 
         
    $htmltail = "</body></html>"     
 
    $htmlreport = $htmlhead + $alertmessagebody + $htmltail 
 
If ($GlobalFailure) 
    { 
        $alertmessagesubject = $AppAssureServer+" - Truncation Failure Alert for "+$GlobalFailure 
    } 
Else 
    { 
        $alertmessagesubject = $AppAssureServer+" - Backup Report - All Pass" 
    } 
 
Send-MailMessage -To $recipient -Subject $alertmessagesubject -SmtpServer $server -From $sender -Body $htmlreport -BodyAsHtml -Encoding ([System.Text.Encoding]::UTF8)