Email Event viewer logs from servers

Home Forums Scripting PowerShell Email Event viewer logs from servers

This topic contains 3 replies, has 2 voices, and was last updated by Avatar todd231 5 months, 4 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Avatar

    Get-WinEvent -LogName $LogName -MaxEvents 1000 -EA SilentlyContinue | Where-Object {$ -in $EventID -and $_.Timecreated -gt (Get-date).AddHours(-24)} | Sort TimeCreated -Descending | Export-Csv c:\transfer\testexport.csv -NoTypeInformation


    Send-MailMessage -From [email protected]-To [email protected] -SmtpServer  -Subject test export -Body $Body -Attachments $Path


    My assumption, probably incorrect, is that the $logname if left blank will gather all event viewer logs, or do I need specify Security, Application, etc for what I want.


    I should be able to set this up as a script to run on a scheduled task as well, if I’m not mistaken.


    disregard guys, I got it…


    Get-Eventlog -log application -after ((get-date).addDays(-1)) -EntryType Error, Warning | export-csv “C:\transfer\appevents.csv”

    Send-MailMessage -To [email protected]-From “[email protected]” -Subject “Application Events” -Attachments “c:\transfer\appevents.csv” -SmtpServer


    This works much, much better!


    You need to specify the log file name, as you have found out.



    Yep! Sure did! Luckily we only need the Application log, so that worked perfectly. As you know, to change what log is exported, just change the “-log application” to “-log system” etc…


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Register for this Petri Webinar!

Software-Defined Backup Storage: Agnostic, Easy and Cloud-Ready

Tuesday, August 27, 2019 @ 1:00 pm EDT

A Scale-Out Backup storage infrastructure is a must-have technology for your backups. In this webinar, join expert Rick Vanover for a look on what real-world problems are solved by the Scale-Out Backup Repository.

Register Now

Sponsored By