Quantcast
Channel: Microsoft Exchange
Viewing all articles
Browse latest Browse all 20055

Exchange 2010 Powershell Script Filtering

$
0
0

Hi all;

I have the following scheduled script, I need the email to be sent to the intended recipient only if the log file contains data because sometimes the generated log file is empty if there are no Fail events.

Please help. Thanks.

Add-PSSnapIn Microsoft.Exchange.Management.PowerShell.E2010

get-messagetrackinglog -ResultSize Unlimited -sender tcn@domain.com -Start (Get-Date).AddDays(-1) -eventid FAIL | Select-Object sender,timestamp,@{Name="Recipients";Expression={$_.recipents}},@{Name="RecipientStatus";Expression={$_.recipientstatus}},messagesubject | Export-CSV D:\CSV\TcnLogs.csv

Send-MailMessage -From "admin@domain.com" -To "TCNeSystemsImports@domain.com" -SmtpServer "exchange.domain.com" -Body "TCN Logs Automated Email" -Subject "TCN Logs" -Attachments "D:\CSV\TcnLogs.csv"


Viewing all articles
Browse latest Browse all 20055

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>