Link to home
Start Free TrialLog in
Avatar of excaltech
excaltech

asked on

Windows Backup Email Notifications - Server 2012 R2 Standard

I have a server running Server 2012 R2 Standard.  I'm attempting to configure an email alert for when the backup completes or fails.  This used to work on Server 2012 (None R2) but for some reason it was removed in R2.  I was able to trigger an email based on a event log but can't complete this anymore.  I created a powershell script that isn't working as well as I believe it was designed for none R2.

This server is running Exchange 2013 and can relay off itself if needed.

Here is the script I've configured to run.

###############################################################
# Receive_Mail_Notification_If_Last_Windows_Server_Backup_Fails_v1.0.ps1
# input : n/a
# output : none (logs)
# Version 0.1
# Changelog : n/a
# MALEK Ahmed - 12 / 01 / 2013
###################

##################
#--------Main  
##################

$Sender = "Backup@domain.com"
$Receiver="personthatcheckstheback@domain.com"
$smtpServer = "Emailserver"

##################
#--------Main  
##################

$backup = Get-WBSummary
$backup.LastBackupResultHR
if ($backup.LastBackupResultHR -ne 1)
{
    #Mail Notification about errors
        $mailbody = "The Last Backup launched on " + (get-item env:computername).Value + " Completed Successfully.`r`n`r`n"
        $mailbody += $backup.DetailedMessage
        $msg = new-object Net.Mail.MailMessage
        $smtp = new-object Net.Mail.SmtpClient($smtpServer)
        $msg.From = $Sender
        $msg.To.Add($Receiver)
        $msg.Subject = "[SUCCESSFUL] The Last Backup launched on " + (get-item env:computername).Value + " Completed"
        $msg.Body = $mailbody
        $smtp.Send($msg)        
}
Avatar of Santosh Gupta
Santosh Gupta

Hi,

not sure about power shell issue, but if you want you can use task scheduler to send the email notification.

User generated image
hope it will help you.
ASKER CERTIFIED SOLUTION
Avatar of Brad Bouchard
Brad Bouchard

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial