Getting to know the get-messagetrackinglog command in Microsoft Exchange

I recently spent some time at a client that was asking for various pieces of information from their Microsoft Exchange server.   Most of what they wanted was quickly and easily accessible through the Exchange PowerShell commandlet get-messagetrackinglog.

First up was a simple command to show all entries from the message tracking log where the recipient of the email was test.comain.com. For this I used:

get-messagetrackinglog | where {[string]$_.recipients -like "*@test.domain.com"}

 

To find all emails from a particular sender and then export to a .csv file I used:

get-messagetrackinglog -resultsize unlimited | where {[string]$_.sender -like "test.domain.com"} | export-csv c:\outfile.csv

 

If you want to track an individual message and output to .csv and all you have to go on is the message ID you can use:

get-messagetrackinglog -messageID "F3C5953201C045409511D4164CF3E4E6897E79@ex.testdomain.com" | export-csv c:\outfile.csv

 

If you want to find all emails from a particular sender between a certain time period and export to a .csv file you can use:

get-messagetrackinglog -sender test.domain.com -Start "02/24/2016 09:00:00" -End "02/24/2016 17:00:00" |ft Timestamp, Source, Sender, Recipients, MessageSubject | export-csv c:\outfile.csv

 

To find a sender from a certain domain and a recipient from a certain domain and then export to a .csv file use:

get-messagetrackinglog -sender test.domain.com -recipients user.anotherdomain.om -resultsize unlimited | Select-Object Timestamp,Sender, {$_.recipients}, MessageSubject | export-csv c:\outfile.csv

 

To get a list of all messages with a particular subject, between a certain date and then export them to .csv use:

get-messagetrackinglog -messagesubject undeliverable -resultsize unlimited -Start "05/11/2016 00:00:00" -End "05/13/2016 00:00:00" | Select-Object Timestamp,Sender, {$_.recipients}, MessageSubject | export-csv c:\outfile.csv

Leave a Reply

Your email address will not be published. Required fields are marked *