An Engineers Notebook

PowerShell | Script to email the last 10 failed backups to an administrator

This function uses the sendemail tool which you can get here.

This is a PowerShell script I have written for general use. This script is run in 3 parts. You can download the script HERE.

$LogReport = Get-WinEvent -FilterXML “<QueryList><Query Id=’0′ Path=’Microsoft-Windows-Backup’><Select Path=’Microsoft-Windows-Backup’>*[System[Provider[@Name=’Microsoft-Windows-Backup’] and (Level=1 or Level=2 or Level=3)]]</Select></Query></QueryList>” -MaxEvents 10 | Select TimeCreated,Id,Message

$LogReport | Convertto-HTML | Out-File C:Report.html

C:sendEmailsendEmail.exe -f [email protected] -t [email protected] -u “TechShizz – Weekly Backup Report” -m Report Attached -a C:Report.html -s -xu <SMTP-Username> -xp <SMTP-Password>

Leave a Reply

Your email address will not be published.