Exchange 2010 report powershell script - no. of emails sent to distribution group

Posted on 2012-08-29
Last Modified: 2012-09-03

Wondering if anyone has a script that can be run on Exchange 2010 logs to show the following:

No. of emails sent to a specific distribution group
Between two dates
Showing number of original emails only (i.e. omits replies/forwards of same email thread)

Thanks in advance,
Question by:Gilesmp
    LVL 52

    Expert Comment

    Get-MessageTrackingLogs - Recipient "Email address of DL" - StartDate "****" -EndDate "***" > C:\data.csv

    - Rancy
    LVL 6

    Accepted Solution

    A few minor corrections...

    Name of the cmdlet is Get-MessageTrackingLog (no s)
    -StartDate and -EndDate should be -Start and -End
    Format of the date for these parameters is MM/DD/YYYY HH:MM:SS

    So here's an example to get all emails sent to "" between 8/29/2012 at 2am and 8/29/2012 at 6pm.

    Get-MessageTrackingLog -Recipient "" -Start "08/29/2012 02:00:00" -End "08/29/2012 18:00:00"

    Also, I like to see certain columns that aren't displayed by default, so I personally would do:

    Get-MessageTrackingLog -Recipient "" -Start "08/29/2012 02:00:00" -End "08/29/2012 18:00:00" |Select Timestamp, EventID, Sender, Recipients, MessageSubject, RecipientStatus |Export-Csv "C:\Message-Tracking-Log.csv"

    With this, you get the date and time of the message, whether it's incoming or outgoing (in your case will always be incoming), who sent the message, who it went to (in your case always the same address), the subject of the email, and you'll get the SMTP status code showing 2xx if it was sent successfully or the error message if it bounced for any reason.
    LVL 3

    Expert Comment

    To not show replies/forwards, you may want to insert something like this, before Export-csv :
    where {MessageSubject -ne "Re:" -or MessageSubject -ne "Fw:"} |
    LVL 3

    Author Closing Comment

    Hi Page,

    Thanks for this.  It does exactly what I want.  As this brings in the email subject and I have to sort the report anyway I just removed FW's and RE's.

    Many thanks,
    LVL 3

    Author Comment

    Hi Akulsh,

    Thanks but that addition throws up an error.  However, as mentioned above, I have addressed the forwards and replies.

    Many thanks,
    LVL 6

    Expert Comment

    Akulsh almost had it:

    |Where {$_.MessageSubject -notlike "Re:*" -and $_.MessageSubject -notlike "Fw:*"}

    Glad I could help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    The problems with reply email signatures

    Do you wish that you could place an email signature under a reply? Well, unfortunately, you can't. That great Exchange/Office 365 signature you've created will just appear at the bottom of an email chain. What a pain! Is there really no way to solve this? Well, there might be...

    Create high volume marketing opportunities using email signatures with these top 10 DOs and DON'Ts of email signature marketing.
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
    The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now