It turn out to be exporting message tracking results to a CSV file is not THAT easy. To get the message tracking log, Exchange shell has Get-MesssageTrackingLog cmdlet. Say we run the following command and export the results to CSV.
get-messagetrackinglog -Sender “SuperMan@DailyMail.com” -Server “DMMail2Server” -Start “6/13/2012 12:45:00 PM” -End “6/13/2012 1:35:00 PM” | Export-CSV .\MailTrackingLogs.csv
The results comes with few “System.String[]” instead of real data. e.g., Recipients, Subject.
I struggle a bit. Then I found this MS Exchange Developers Team blog. Sadly the command wasn’t in text, it was screenshot of the Exchange Shell.
The trick is to pipe the Get-MessageTrackingLog results to Select command. Type selected objects as string object in a code block like {$_.Recipients}. That did the trick. Here is the same full command.
Get-MessageTrackingLog -Sender “SuperMan@DailyMail.com” -Server “DMMail2Server” -Start “6/13/2012 12:45:00 PM” -End “6/13/2012 1:35:00 PM” | Select Sender,{$_.Recipients},{$_.RecipientStatus},MessageSubject,TimeStamp, EventId, Source, SourceContext,MessageId,InternalMessageId,ClientIP,ClientHostName,ServerIP,ServerHostName,ConnectorId,TotalBytes,RecipientCount,RelatedRecipientAddress,Reference,ReturnPath,MessageInfo | Export-Csv .\MessageTrackingLog.csv
Nice article!
got very handy! Thanks a lot!
Nice tip. Thank You
Dumb question, where does .\MessageTrackingLog.csv make the file export to? .\ means the local computer, but would that put it at the root of C:\ ?
Update (answer to my own question) – it puts it in the same directory as your management shell is running. In my case C:\Windows\System32. Like I said, dumb question! ^.^
Nice article. Keep up the good work.
I had exported logs to text and then I realized I needed it CSV format. Then I found out below article which explains how to convert Text logs to CSV format.
http://www.theservergeeks.com/how-to-convert-txt-logs-to-csv/