Receive total send and received emails Exchange 2010

We are using Exchange 2010. I would like to retrieve a list of total sent emails and received emails from all users in the work place for 30 days. The list should have all the users' names, then total of sent and received emails.

I have tried the example code below and tried to change this to no avail.

Get-MessageTrackingLog -Recipients [email protected] -start “10/22/2011 00:00:00” -end “11/21/2011 11:59:00” -EventId "receive" | measure-object

Get-MessageTrackingLog -sender [email protected] -start “10/22/2011 00:00:00” -end “11/21/2011 11:59:00” -EventId "send" | measure-object


Solution 1:

"By default, the maximum age for any message tracking log file is 30 days" - unless you've changed the message tracking log defaults, you are very unlikely to get a year old data from there (unless you have had virtually no messages so the 10 MB per log file limit has not been hit more than 30 days in the past).

If you need this kind of data to persist, change the maximum age / directory size limit for the logs as described in the docs.

Another point is that the tracking log does not contain user information - it just contains senders and recipients - which might or might not map to actual users of your infrastructure.

Other than that, you could just pipe the result of Get-MessageTrackingLog to group-object for grouping and counting. For grouping by senders, this would be rather trivial:

Get-MessageTrackingLog -start “10/22/2011 00:00:00” -end “11/21/2011 11:59:00” | group-object -Property Sender

Grouping by recipients is trickier as the "Recipients" field returned by Get-MessageTrackingLog is multivalued - i.e. could contain more than one recipient. Prepending a Select-Object -ExpandProperty helps here:

Get-MessageTrackingLog -start “10/22/2011 00:00:00” -end “11/21/2011 11:59:00” | select-object -ExpandProperty Recipients | group-object

The result set is going to look somewhat like this:

Count Name                      Group
----- ----                      -----
   44 [email protected]       {[email protected], [email protected], ...}
   11 [email protected]      {[email protected], [email protected], ...}
   36 some.address@foreigndo... {[email protected], some.address@for...}
[...]