Link to home
Start Free TrialLog in
Avatar of Tony Giangreco
Tony GiangrecoFlag for United States of America

asked on

Need sent Mail Stats from Exchange 2007

On a Windows 2008 R2 Server running Exchange 2007, how do i generate a quick report of incoming and outgoing mail per day, week and month for all users in the domain?
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Use Message Tracking Log to accomplish this...
$Date = get-date
Get-MessageTrackingLog -Server <hub transport> -Start "$Date.AddDays(-1)" -End "$Date" | measure

Open in new window


This will provide all of the messages internal and external for 1 day. Just modify the -1 and run the script.

Will.
Avatar of Tony Giangreco

ASKER

Thanks, I'll try it in the morning.
I opened powershell on the exchange server and ran that query. I received a syntax error

The '<' operator is reserved for future use.
At line:1 char:33
+ Get-MessageTrackingLog -Server < <<<< hub transport> -Start "$Date.AddDays(-1)" -End "$Date" | measure
    + CategoryInfo          : ParserError: (<:OperatorToken) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupported
The < hub transport server> is just an example of what needs to go in there. You need to remove the brackets and type in your own hub transport server name. Then rerun the command again.

Will.
Ok, made that change. Another error


[PS] C:\Windows\system32>CD\
[PS] C:\>$Date = get-date
[PS] C:\>Get-MessageTrackingLog -Server HPM5 -Start "$Date.AddDays(-1)" -End "$Date" | measure
Get-MessageTrackingLog : Cannot bind parameter 'Start'. Cannot convert value "05/31/2015 13:03:55.AddDays(-1)" to type "System.DateTime". Error: "The string was not recognized as a valid DateTime. There is a unknown word starting at index
20."
At line:1 char:43
+ Get-MessageTrackingLog -Server XXM5 -Start <<<<  "$Date.AddDays(-1)" -End "$Date" | measure
    + CategoryInfo          : InvalidArgument: (:) [Get-MessageTrackingLog], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.TransportLogSearchTasks.GetMessageTrackingLog

[PS] C:\>
I have just tested this in my lab and it works without any issues.

Try removing the quotes around $date.addDays(-1).

I ran this exact command in my lab and it worked.
Get-MessageTrackingLog -Server cashub -Start $date.addDays(1-) -End $date | measure

Open in new window


I got all of the emails for that duration.

Will.
I ran it twice with -1 and -2 on the end date. the 2nd time, I received a warning:

[PS] C:\>Get-MessageTrackingLog -Server HPM5 -Start $Date.AddDays(-1) -End $Date | measure
Count    : 607
Average  :
Sum      :
Maximum  :
Minimum  :
Property :

[PS] C:\>Get-MessageTrackingLog -Server HPM5 -Start $Date.AddDays(-2) -End $Date | measure
WARNING: There are more results available than are currently displayed. To view them, increase the value of the ResultSize
Here is the output from tee 2nd run. I missed copying it

[PS] C:\>Get-MessageTrackingLog -Server HPM5 -Start $Date.AddDays(-2) -End $Date | measure
WARNING: There are more results available than are currently displayed. To view them, increase the value of the ResultSize
parameter.

Count    : 1000
Average  :
Sum      :
Maximum  :
Minimum  :
Property :
ASKER CERTIFIED SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Worked perfect!  Thanks for the help.