Configuring email alerts for Windows Server Backups

 In administration, Backup, Microsoft, Monitoring, Server Core, Windows

Binary Royale is an IT consultancy company based in the East Midlands. We spend all of our time with clients, helping them to make good decisions about their IT. When we come across issues that would be useful to others we “try” to post the answers on our website – . We cover Derby and Derbyshire, Nottingham and Nottinghamshire mainly, but do also have clients further afield. Please browse our website to see what we offer – thanks, and enjoy the blog

Windows Server backup is a credible backup solution for small environments when backup space is plentiful and an integrated centrally managed solution is not required or not affordable. However one thing that is missing from WSB is any sort of alerting to let you know when your backups have completed or failed. Without this it’s necessary to manually login and check on the backup as they are run – a tedious waste of your time, I’m sure you’ll agree.

However there is a better solution. Using Windows Task Scheduler and a few simple powershell scripts it’s possible to get email alerts sent to you as soon as your backup job completes – or fails.

I’ll assume that you have WSB configured and working on the server in question – there are plenty of on-line resources available to help you get this set up and working.

    1. Create you alert scripts. You need 3 Powershell scripts – 1 each for a successful backup, a failed backup and another to alert you that the backup disk is full. The content for each is as follows:
      $SmtpClient = new-object
      $SmtpServer = "x.x.x.x"
      $ = $SmtpServer
      $computer = gc env:computername
      $From = ""
      $To = ""
      $Title = "Backup Complete on " +$Computer
      $Body = "Backup Completed Successfully " + $computer

      The details in red need to be changed to suit your environment, and are the same in all 3 scripts. The details in green are different in each script, and should be changed to suit the script – i.e. “Backup Failed on ” or “Backup drive full on “. I save the scripts as BackupComplete.ps1, BackupFailed.ps1 and BackupFull.ps1. I put these in c:usersadministrator, but the location is up to you really.

    2. You can test the scripts at this point by running them manually in Powershell. You may need to set the script execution policy to remote signed to allow the script to run if this hasn’t already been done on your server. Run
      get-help about_signing

      at the powershell prompt for more info. If the script runs, but you don’t receive the emails, check your mail server config to make sure that it will allow the server to send via it without authentication.

    3. Open Windows Server Manager on the server running the backup, or a management server if the backup is running on a Server Core machine. Expand the Configuration node and the Task Scheduler sub-node. Click on Task Scheduler Library sub node.
    4. Right click in the Task Scheduler Library middle pane, and select Create New Task. The Create New Task dialog box will appear.
    5. On the General tab, give the task a name, a description if you like, and change the Security options as below:
    6. On the Triggers tab, press the “New” button to add a new Trigger. Select “On an Event” from the Begin the task drop-down. Select Microsoft-Windows-Backup/Operational for the Log, Backup for the Source, and specify the correct EventID depending on which task you are creating. The backup completed EventID is 4, the backup failed EventID is 5, and the backup full EventID is 50.
    7. On the Actions tab, press the “New” button to add a new Action. Select Start a program from the Action dropdown list. Enter powershell for the program, and add the argument that points it to the script that you created earlier. e.g. for the backup completed task, I would set the argument to:
      -command “& c:usersadministratorBackupComplete.ps1”
    8. For the Conditions tab, you can leave the Settings as they are:
    9. On the Settings tab, adjust the settings as below:
    10. The History tab will not contain any info at this stage, so you can press OK to save the task. You will be prompted to enter the server administrator password.
    11. Repeat items 4 – 10 to add the second and third tasks to the task scheduler.
    12. You should now be able to right click on each task and run it manually, and the corresponding email should duly arrive in the appointed inbox. If not, check that the scripts run properly from the Powershell prompt, and that you have entered the script arguments correctly.
    13. You should now receive an email after your next scheduled backup cycle, letting you know how that backup went. However, it’s prudent to manually keep an eye on the backups until you’re happy that the emails are reporting the backup status correctly.

Thanks for reading.

Recommended Posts
Showing 3 comments
  • Jason

    How do you enter the SMTP server credentials?

    • Andy

      Hi Jason,

      This script doesn’t allow for SMTP credentials. We’ve got around the issue by allowing the servers in question to connect without credentials. As we also manage the SMTP server, we’re able to do this, but it might not work in an environment where you don’t have that control.

      Good luck,


pingbacks / trackbacks

Leave a Comment

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search