Are you running the 2.0 beta?

 

This should be TimeSpan arithmetic.

 

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

 

Regards,

 

Michael B. Smith

MCITP:SA,EMA/MCSE/Exchange MVP

http://TheEssentialExchange.com

 

From: Campbell, Rob [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 24, 2008 1:37 PM
To: MS-Exchange Admin Issues
Subject: RE: Inbound/Outbound Mail Stats

 

Is the first line of the script you copied 

 

$today = get-date

 

?

 

  _____  

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

 

Wow Rob, that is really cool.  And, it's forcing me to learn a little more
about powershell-my knowledge is still greatly limited by what I've actually
used thus far.

 

So, I added my servername and changed the outfile to a path that exists
(D:\foldername\something.csv), and saved as a .ps1 file.  In the Exchange
mgmt shell, when I run the ps1 file, I get the following:

 

[PS] c:\myprompt>c:\scripts\getexternalmailstats.ps1

 

Cannot convert value "7/24/2008 10:15:49 AM" to type "System.Decimal".
Error: "

Invalid cast from 'DateTime' to 'Decimal'."

At C:\scripts\getexternalmailstats.ps1:5 char:22

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

You cannot call a method on a null-valued expression.

At C:\batch\plscriptlibrary\getexternalmailstats.ps1:5 char:44

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

 

Any ideas?  I'm barely deciphering what you've written at the moment =)

 

Thanks,

Bonnie

 

From: Campbell, Rob [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 24, 2008 9:18 AM
To: MS-Exchange Admin Issues
Subject: RE: Inbound/Outbound Mail Stats

 

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. 
****************************************************************************
**********************

 

 

 

 

****************************************************************************
**********************
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