Tuesday, June 10, 2014

Daily Mail Flow Summary Report

From - http://exchangeserverinfo.net/2013/03/daily-mail-flow-summary-report/

Hello All
Thanks to one of user on Microsoft Exchange 2010 forum who requested a way to generate details of emails processed by each HUB server deployed in environment, that I am getting chance to write & share this script with all.
Based on the request and some customization, this script generates email message statistics processed per HUB server in last 24 hours, generates output in HTML format, sends HTML email from output file. The statistics include:
  1. Total Message Count Processed
  2. Total Message Size in GB
  3. Average Message Size Processed MB
  4. Total Message Count from External Domains
  5. Total External Message size from External Domains in GB
  6. Average Message Size from External Domains in MB
  7. Total Message Count from Application Relay
  8. Total Message Size from Applications in GB
  9. Average Message Size from Applications in MB.
Based on your requirements, you can remove some of parameters or add more parameters to same script and generate appropriate output for your environment
How this script works: I will lay down some important points of script that you should be aware about:
  1. $fileName = “C:\Test\MessageSummaryReport.htm” – This is the name of HTML output file along with full local path on server.
  2. $startdate = $enddate.Add(-24).Date – This line defines to script that we’re looking for processing data in past 24 hours. If you want to process more data, you can change 24 accordingly, for example for processing 10 days worth of data, 24 will be replaced by 240 accordingly.
  3. $messages = Get-MessageTrackingLog -Server $serverName -start $startdate -end $enddate -ResultSize Unlimited | where-object {$_.EventID -eq ‘Receive’} – Core of script where it generates the required statistics from each server for data processing.
  4. $Externalmessages = $Messages | where-object {$_.EventID -eq ‘Receive’ -and $_.ClientHostName -like “*Edge*”} – Secondary line for filtering emails which are being sent via Exchange 2010 Edge servers. In our environment, edge server names have keyword “Edge” in them and hence that’s the filter I used. Based on your environment configuration, you can change the filter to use receive connector name or different keyword accordingly.
  5. $Relayedmessages = $Messages | where-object {$_.EventID -eq ‘Receive’ -and $_.ConnectorID -like “*Applications*”} – Same principle as above only this time we’re looking for traffic at receive connector level which has keywords “Applications” in its name. Based on your environment configuration, you can filter on another parameter or different keyword accordingly
  6. sendEmail Reporting@Contoso.com Administrator@contoso.com “Contoso Daily Mail Flow Summary” 10.0.0.1 $filename – This generates email to your needed recipients. The format of command is SendEmail <from address> <to address 1,<to address 2> “<Message Subject>” “<SMTP Server FQDN OR IP Address>” “<HTML file>”
Hope above script helps you monitor or report on your environment more closely and in automated fashion. Hence reducing your efforts and keeping Exchange environment healthy.
Please add any additional ideas to comment section.
Thank You !

No comments:

Post a Comment