I hacked this out of a script I already had written.  If you schedule
this to run once a day, it should accumulate the internet email stats
from the previous day to a .csv file.  

 

You'll need to change the $ht variable to the name of your server.  

 

You can go back farther than one day to back fill by manipulating the
$rundate variable. $today - 1d will get the stats from yesterday.  If
you change it to $today -2d it will get the stats from the day before
yesterday, etc. within the limit of your message tracking log retention.

 

It has to run on an E2K7 server, or a workstation with the Exchange
Management Shell installed.

 

If you want to use it with SCCM you can modify it to write an event to
the application event log with the data, and have SCCM pick up and
report on that event.

 

 

 

 

 

 

 

$today = get-date

$ht = "server name here"

 

$headings = '"Date","Sent","Send MB","Received","Receive MB"'

$rundate = $($today - 1d).toshortdatestring()

$outfile = "internet_email_stats.csv"

 

if (!(test-path $outfile)){ac $outfile $headings}

 

$recv_recs = get-messagetrackinglog -Server $ht -EventID "RECEIVE"
-Start "$rundate 12:01:00 AM" -End "$rundate 11:59:59 PM" -resultsize
unlimited

$smtp_recvs = $recv_recs |? {$_.source -eq "SMTP"}

 

$send_recs = get-messagetrackinglog -Server $ht -EventID "SEND" -Start
"$rundate 12:01:00 AM" -End "$rundate 11:59:59 PM" -resultsize unlimited

$smtp_sends = $send_recs |? {$_.source -eq "SMTP"}     

 

foreach ($smtp_recv in $smtp_recvs){$bytes_recv +=
$smtp_recv.totalbytes}

 

foreach ($smtp_send in $smtp_sends){$bytes_sent +=
$smtp_send.totalbytes}

 

            $mbytes_recv = $bytes_recv/1mb

            $mbytes_sent = $bytes_sent/1mb

 

$outstr = $rundate + "," + $smtp_sends.count + "," + $mbytes_sent + ","
+ $smtp_recvs.count + "," + $mbytes_recv

ac $outfile $outstr

 

 

________________________________

From: Miller Bonnie L. [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 24, 2008 7:29 AM
To: MS-Exchange Admin Issues
Subject: Inbound/Outbound Mail Stats

 

Exchange 2007 SP1, one server with all roles.  What is the best way to
get numbers that show our average inbound (received)/outbound (sent)
mail stats per day?  We are looking for numbers of messages that travel
to/from the Internet.

 

We do not currently have anything like MOM nor SCCM, but will be
bringing in SCCM at some point if that could help.  If there are
specific performance counters to track, that works for me-just don't
know which ones to look at.  If Exchange already stores this data
somewhere and I just need to pull it, even better.

 

Thanks,
Bonnie

 

 

 

**************************************************************************************************
Note: 
The information contained in this message may be privileged and confidential 
and 
protected from disclosure.  If the reader of this message is not the intended  
recipient, or an employee or agent responsible for delivering this message to  
the intended recipient, you are hereby notified that any dissemination,   
distribution or copying of this communication is strictly prohibited. If you  
have received this communication in error, please notify us immediately by  
replying to the message and deleting it from your computer. 
**************************************************************************************************

~ Ninja Email Security with Cloudmark Spam Engine Gets Image Spam ~
~             http://www.sunbeltsoftware.com/Ninja                ~

Reply via email to