MSExchangeGuru.com

Learn Exchange the Guru way !!!

 

Powershell cmdlet to track emails send to one specific email id/mailbox/DL

This is not a new cmdlet but I customized it a bit so that we get some “presentable” output

Scenario:

We need to track all emails send to a mailbox/mail enabled DL with the name – team@msexchangeguru.com

Condition 1 – Get all failed/undeliverable emails:

Get-Messagetrackinglog -Recipients: team@msexchangeguru.com -EventID "FAIL" -Start "5/4/2011 9:00:00 AM" -End "5/10/2011 5:00:00 PM" |ft Timestamp, Source, Sender, Recipients, MessageSubject >>C:output.txt
Condition 2 – Get all success emails

Get-Messagetrackinglog -Recipients: team@msexchangeguru.com -EventID "RECEIVE" -Start "5/4/2011 9:00:00 AM" -End "5/10/2011 5:00:00 PM" |ft Timestamp, Source, Sender, Recipients, MessageSubject >>C:output.txt

This will give you the output in the form:

Timestamp Source Sender Recipients MessageSubject

Source “SMTP” means it’s an external email and “STOREDRIVER” means processed internally

Again remember to edit the properties of the powershell window to make it 400×300.

Ratish Nair

MVP Exchange

Team@ MSExchangeGuru.com

8 Responses to “Powershell cmdlet to track emails send to one specific email id/mailbox/DL”

  1. Gibs Says:

    You are a life saver my friend. Great script…

  2. mike f Says:

    not working for me, did i miss something??

    PS C:\Windows\system32> Get-Messagetrackinglog -Recipients: User.name@mydomainname.com -EventID “RECEIVE” -Start ” 2/1/2014 9:00:00 AM” -End ” 2/05/2014
    5:00:00 PM” |ft Timestamp, Source, Sender, Recipients, MessageSubject >>C:\output.txt

  3. mehdi Says:

    that was very useful.Thanks.

  4. Bobjan Says:

    Mike you need to run this from hub server the it will get the results from that specific server.
    if you have multiple servers try below..

    Get-TransportServer |Get-Messagetrackinglog -Recipients: User.name@mydomainname.com -EventID “RECEIVE” -Start ” 2/1/2014 9:00:00 AM” -End ” 2/05/2014 5:00:00 PM” |ft Timestamp, Source, Sender, Recipients, MessageSubject >>C:output.txt

  5. WilliamNB Says:

    I got a few errors with this, so Ive changed it somewhat:
    Get-Messagetrackinglog -Recipients: user@mydomain.com -EventID “RECEIVE” -Start (get-date).AddDays(-1) -End (get-date)| ft Timestamp, Source, Sender, Recipients, MessageSubject >>C:\Script\output.txt

    By changing to (get-date).AddDays(-1) I avoid having to do any string conversions. The (-1) is easily changeable – changing to (-7) will give all messages for the past 7 days.
    I also had a permissions error, with the original script trying to write to the root of C:, so I created a new folder and changed the output file accordingly.

    Thanks for sharing an otherwise great script!

  6. Pratik Says:

    Can we use same script to see sent mail.

  7. Ratish Nair Says:

    Take a look at the cmdlets in this article:
    https://msexchangeguru.com/2015/03/10/message-tracking/

  8. G-Man Says:

    You can cheat and do this through the EMC in the exchange toolbox, under message tracking. It produces similar powershell code at the bottom for you. You could also pipe this through a csv instead of a txt file using ” | export-csv C:\filename.csv”. Its a little bit easier to manage.

Leave a Reply

Categories

Archives

MSExchangeGuru.com