Home » Exchange Server » Get-DailyBackupAlerts.ps1 V1.07 Released

Get-DailyBackupAlerts.ps1 V1.07 Released

Most of my publicly available PowerShell scripts start out by solving my own problem first, before they were cleaned up and released to the world. One of the earliest examples of this is my Get-DailyBackupAlerts.ps1 script, which checks Exchange database backup time stamps and sends an email report to alert you to any that have not recently been backed up. I can’t tell you how many times this script avoided a potential disaster in environments that I managed, and I’ve heard from dozens of other people in the Exchange community that tell me it saved their bacon as well.

Get-DailyBackupAlerts.ps1 was first developed in 2011, and it would have been developed for an Exchange 2007 environment at first. Over time I added support for Exchange 2010 and database availability groups, but after that I only did a few bug fixes and stopped updating the script in 2014 since it just kept working for new versions of Exchange without any changes needed.

This week I had some time to look at the code again. I wanted to update the script so that it handled differential backups (until now it only looked at full and incremental backups), using code that I wrote for Exchange Analyzer. As it turns out, retrofitting the new code to the old script wasn’t as simple as I thought it would be. But it gave me a good excuse to tidy up a bunch of other things that were symptoms of having written the script over five years ago, as well as add a few enhancements that were suggested on GitHub.

And so I am pleased to release V1.07 of Get-DailyBackupAlerts.ps1, which includes:

  • Handling for differential backups
  • Color-coded status in report (alert/OK)
  • Change to calculation of hours since last backup to base it on UTC time, which is more accurate for multi-region environments

get-dailybackupalerts

You can download the new version of the script from the TechNet Script Gallery or GitHub.

Paul is a Microsoft MVP for Office Servers and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul is a co-author of Office 365 for IT Pros and several other books, and is also a Pluralsight author.
Category: Exchange Server

17 comments

  1. Chris Gecks says:

    Hi Paul,

    I was wondering if you could help me out. I am running into some issues with the updated Get-DailyBackupAlerts.ps1 V1.07 script.

    You cannot call a method on a null-valued expression.
    At C:PS_ScriptsGet-DailyBackupAlerts.ps1-1.07Get-DailyBackupAlerts.ps1:371 char:5
    + $LatestBackup = ($LastBackups.GetEnumerator() | Sort-Object -Property Value) …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:PS_ScriptsGet-DailyBackupAlerts.ps1-1.07Get-DailyBackupAlerts.ps1:424 char:12
    + elseif ($($LatestBackup.Value.ToInt32($null)) -gt $threshold) {
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    PS C:PS_ScriptsGet-DailyBackupAlerts.ps1-1.07>

    If you have any questions or concerns please let me know.

    Thanks for all your time and help.

    Kindest Regards,
    Chris Gecks

  2. Bruce McKay says:

    Seems to work ok.
    One enhancement after getting concerned about the last date time stamp in the email, the time was in UTC and we are NZST which is +12 hours.
    Thought there was a backup problem at first glance !
    Thanks!

  3. Trevor Procyshen says:

    We have some old Exchange 2010 test databases that have not been backed up in over 3000 hours yet they are not flagged as an alert by the script, the status shows OK. Any ideas why this might happen?

  4. Shannon says:

    Hey Paul,

    I see that there is a new script version out there. We had issues with databases not showing as being backed up when Exchange and Barracuda were showing that they were. This was version 1.07 so I reverted back to the previous one and everything was working. I’ve downloaded 1.08 and will see if the issue persists. If there are, do you want me to send the log file over?

  5. Obi DG says:

    Any way to to allow for Display name for “From” email address.

    If your previous iteration that we’re been using I was able to enter something like.

    Mail Monitor

    When I try that not I get errors because PS isn’t parsing the that field correctly. I’ve played around with the XML to see if I can add it. I know last resort is just editing the script directly, but thought I’d ask before doing that.

  6. Dave says:

    Hi Paul,

    What would I need to do in order to add a couple of things to the report? Like if I want to add Last Full and Last incremental rather than just reporting the type of backup that was last performed. Look forward to your response.

    Thanks
    Dave

Leave a Reply

Your email address will not be published. Required fields are marked *