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
"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
togroup-object
for grouping and counting. For grouping by senders, this would be rather trivial:Grouping by recipients is trickier as the "Recipients" field returned by
Get-MessageTrackingLog
is multivalued - i.e. could contain more than one recipient. Prepending aSelect-Object -ExpandProperty
helps here:The result set is going to look somewhat like this:
Not sure what you are looking for (still), as I am unsure where you are with the question and how much the comments have helped you so far but, the following script helped me all the way:
http://gallery.technet.microsoft.com/office/f2af711e-defd-476d-896e-8053aa964bc5