I recently wrote about gathering user profile data for Exchange Server 2003 and 2007 by using the Exchange Server Profile Analyzer tool. As a re-cap the EPA tool uses WebDAV to interrogate the mailboxes and generates user profile data, including..
Note: This information is vital for performing good quality Exchange server scaling.
The problem of course is that Exchange Server 2010 does not include WebDAV and so the EPA tool will not work. This poses an interesting problem, however I am happy to report that we have a solution…
One of the nice things about Exchange 2007 and Exchange 2010 is that we can interrogate the message tracking logs via PowerShell. This provides us with a nice way to query what the Exchange Server is doing. Usefully the message tracking logs include sufficient information for us to approximate our user profile data, without needing the EPA.
After asking around internally within Microsoft about how to gather EPA data for Exchange Server 2010, it became apparent that PowerShell would be the best way to interrogate the message tracking logs. I mentioned to a few people that I was going to write something up over the next few weeks, however before I had a chance to even put any significant thought into the task, someone sent me a copy of the following script which I have uploaded here.
Now, I must confess that despite my best efforts I have been
unable to track down the original author! The author of this script is Rob Campbell, more about the scripts development can be found here…
The script basically works by parsing the messaging tracking logs of your Exchange Servers and then tabulates the information into a CSV file for analysis in Excel. To provide some data to parse I configured a loadgen test against 10 mailboxes with a heavy profile, this should approximate to around 80 messages received and 20 sent per user.
The MessageStats script has a single command line parameter which controls how many days back it will look in the tracking logs. For my lab test I only wanted a single days worth, so I just tagged "1" on the end of the PS1 script.
So, now we have our CSV file that we can open in Microsoft Excel, however the data required some work before we can get our EPA values. The following screenshot shows the raw data open in Excel.
The best way to process the data is to convert it into a table..
You should now have a table with the following columns…
Note: Due to my test lab being very small I have added a filter to remove any non-loadgen accounts from the data analysis.
In the Total row at the bottom of your table add "AVERAGE" subtotals for "Received Total" and "Sent Unique Total".
In the "Received MB Total" column total cell, add in an "AVERAGE" subtotal, then edit the formula in the cell and divide that value by the Total Row average for "Received Total", then multiply the result by 1024 – this will report the average message size in KB.
In the "Sent Unique MB Total" column total cell, add in an "AVERAGE" subtotal, then edit the formula in the cell and divide that value by the Total Row average for "Sent Unique Total", then multiply the result by 1024 – this will report the average message size in KB.
We now have all of the information that we require…
So, using this technique we have managed to approximate our user profile to a fair degree of accuracy without needing to logon to any mailboxes!. I suspect that this method is accurate to around +/- 10% which is totally acceptable in this context.
Obviously there is a caveat here that I have only performed some rudimentary testing in a fairly small lab environment, so if you do run this in production and find that it generates weird results, or that it validates your already proven EPA data, then feel free to drop me a note to let me know
The script was developed by Rob Campbell.
Available here: gallery.technet.microsoft.com/.../bb94b422-eb9e-4c53-a454-f7da6ddfb5d6
Referenced from here: blogs.technet.com/.../use-powershell-to-track-email-messages-in-exchange-server.aspx
Thanks both Rob / Neil :)
Thanks for this amazing Script,I wanted to run the script to get info for the last 30 days, I ran ".\MessageStats.ps1 30" while the result only returned today's data :(Is there something I'm messing or what?
Mohamed, this script just summarizes all log entries for specific users and write this sum in output file. If you try specify different values of offset, you can see, that values in output file changes.
I just make a little modification in script:
1. For runing script on servers, that has non-"en-US" time format settings (script using .toshortdatestring method, that different in different regional formats) you need modify strings 8 and 9 to this code:
$rundate = $(($today).ToString("MM\/dd\/yyyy"))
$startdate = $((Get-Date).AddDays($startoffset).ToString("MM\/dd\/yyyy"))
This is en-US short date\time format.
2. For displaying user Display Names in output files modify line 58 to:
User = $((Get-Mailbox -Identity ($address)).DisplayName)
Don't use .split method because script don't work if you UserPart in primary SMTPAddress is different from Alias value. And if your users display name in non-Unicode encoding you must also change CSV-file encoding in line 177.
I.e. $stat_recs | export-csv $outfile -notype -Encoding Unicode
3. To running script without administrative rights (without elevation to built-in administrator's privileges) modify lines 12 and 14 to:
$outfile = "$home\Documents\" + "email_stats_" + $outfile_date + ".csv"
$dl_stat_file = "$home\Documents\" + "DL_stats.csv"
By default script trying to write output in System32 directory.