I recently needed to setup a way to email a weekly summary of event logs, here’s how I did it:
Powershell Script to Export Events
Get-Eventlog -log WebEventLog -after ((get-date).addDays(-7)) -EntryType Error, Warning | export-csv "C:\scripts\sysevents.csv"
Email .csv File (emailEvents.ps1)
Send-MailMessage -To Rob.Pucci@somedomain.com -From "SysEvents@somedomain.com" -Subject "[WebEventLog] Event Logs from servername" -Attachments "c:\scripts\sysevents.csv" -SmtpServer mail.somedomain.com
Scheduled Command
powershell -command "& 'emailEvents.ps1' "