I can’t find anywhere in the Windows Server 2012 (R2) settings to allow an email notification when a server backup completes successfully. Windows Server 2012 Essentials has a nice feature that you allows you to get email reports on your backup status. This helps keep tabs on your server without logging in everytime. I wanted a similar notification for when a Windows Server 2012 backed up successfully.
After some research online this is how I found to accomplish this task.
Part One of Tutorial
Lets create a Powershell script. This script will allow us to send email.
Use this Powershell script. Please note your username and password isn’t encrypted. There are ways to encrypt your password but the following tutorial doesn’t show you how to.
$EmailFrom = “[email protected]”
$EmailTo = “[email protected]”
$Subject = “Notification from XYZ”
$Body = “this is a notification from XYZ Notifications..”
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“username”, “password”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
Just change $EmailTo, and username/password in $SMTPClient. For the credentials don’t include @gmail.com in your username.
Thanks to Christian Muggli for this script.
Log into your Gmail account and make sure two factor authentication is turned off. Also make sure less secure apps are enabled. Visit this site https://www.google.com/settings/security/lesssecureapps to find out if it is enabled or not. If it isn’t enabled you will get this error message.
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 authentication required.
Save the file on the hard drive and make a note where it is saved.
Now for part two of the tutorial.
Step One: Open Task Scheduler
Step Two: Click Create Task and Name it “Successful Windows Backup”
Step Three: Next go under the Triggers tab. Click New Trigger. Click Begin the task on an event.
Step Four: Drop down the box next to Log and select Microsoft-Windows-Backup/Operational. Go down to the next box and select Backup for Source.
Step Five: Next we will need to find the Event ID of a successful Windows Server 2012 in Event Viewer. The Event ID for a successful backup is 4 on a Windows Server 2012. You can verify this information by going into Event Viewer and underneath this folder string, Microsoft > Windows > Backup > Operational. Under operational you will find some logs about backup information. Enter the Event ID in the “event id” box.
Make sure the Enabled box is checked and select OK.
Step Six: Now go underneath the Actions box and select New. Beside Action select Start a program. In the program box enter powershell.exe. In the arguments field enter the location of the Powershell script (Last step of part One). In my example, they were stored underneath C:\scripts\mailer.ps1 . Click OK and save the schedule.
This should enable you to receive backup notifications when your Windows Server 2012 does a backup successfully. I also was able to get this script to work on a SBS 2011.
Let me know if this tip helps you by posting in the comments below. If you run into any issues please inform me.
This was posted by techspeeder.
Special thanks to Blue Compute for making my research easier.