Jump to content
  • entries
    142
  • comments
    0
  • views
    87565

Azure Backup Email Notification


proximagr

2368 views

 Share

I was looking for a free solution to have an email notifications for Azure backup. After reading other blogs and technet site I end up to use PowerShell Send-MailMessage attached to the Azure Backup Logs. In short, when the Azure Backup log is created, the script lists the last 2 days events, creates an html file and mails the report with the html as attachment to you.

 

First find the Azure backup Event Log, it under “Applications and Services Logs, CloudBackup, Operational” and select to attach a task to the log. This will trigger the task on every event created under this log. On the other hand you can attach the task to a specific event.

 

Create a Task and attach the below PowerShell script. Here you will find the powershell.exe “C:\Windows\System32\WindowsPowerShell\v1.0″

 

Crate a folder c:\IT and Copy the below script on a text file and name it “eventemail.ps1″. Finally change the required fields.

 

$date = (Get-Date).AddDays(-2)
$event = Get-WinEvent -FilterHashtable @{ LogName = "cloudbackup"; StartTime = $date; }
$event | ConvertTo-Html message,timecreated | Set-Content c:\it\backup.html

 

if ($event.EntryType -eq "Error")
{
$PCName = $env:COMPUTERNAME
$EmailFrom = "FROM_EMAIL_HERE"
$EmailTo = "YOUR_EMAIL_HERE"
$EmailSubject = "Server $PCName Backup Failure report"
$SMTPServer = "SMTP_SERVER_HERE"
Write-host "Email Sent"
Send-MailMessage -From $EmailFrom -To $EmailTo -Subject $EmailSubject -body "$($event.Message) $($event.TimeCreated)" -Attachments "c:\it\backup.html" -SmtpServer $SMTPServer
}
else
{
write-host "There is no error. Below the logs files."
$event
$PCName = $env:COMPUTERNAME
$EmailFrom = "FROM_EMAIL_HERE"
$EmailTo = "YOUR_EMAIL_HERE"
$EmailSubject = "Server $PCName Backup Success report"
$SMTPServer = "SMTP_SERVER_HERE"
Write-host "Sending Email"
Send-MailMessage -From $EmailFrom -To $EmailTo -Subject $EmailSubject -body "$($event.Message) $($event.TimeCreated)" -Attachments "c:\it\backup.html" -SmtpServer $SMTPServer
}

 

The “write-host ” lines can be removed. They are useful only for troubleshooting by running the script manually on powershell.

 

source: http://www.e-apostolidis.gr/microsoft/azure-backup-email-notification/

 Share

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...