Powershell – Get all emails sent to particular email address and not the mailbox (alias’)

exchange-2010microsoft-office-365powershell

I'd like to see all emails sent to a particular email address rather than the full mailbox with all alias'.

e.g. if bob@example.com is the primary email address and bob@example2.com is an alias, i'd like to see only messages that were sent to bob@example2.com.

Messagetrackignlog seems to bring back all emails sent to both aliases.

I'm using exchange 2010 and O365,

Thanks you

Best Answer

So you need to use the Exchange Powershell Get-MessageTrackingLog cmdlet. https://technet.microsoft.com/en-us/library/aa997573%28v=exchg.160%29.aspx

But what you want to do is not in the official documentation.

For an On Premise Exchange Server

Here is the command you want to run.https://technet.microsoft.com/en-us/library/aa997573%28v=exchg.160%29.aspx

Get-MessageTrackingLog -Recipients bob@example2.com | where {($_.EventId -eq "RECEIVE")}

This will give you the emails that were received by bob@example2.com. If an email went to both bob@example2.com and bob@example.com, then you may see both email addresses in the Recipients column.

You can also use the next command to show all emails in the mailbox (primary email address) and then select the messages that were sent to the secondary email address. Doing this should display the same list of emails as from the first command but can be used to verify you are seeing the proper emails.

Get-MessageTrackingLog -Recipients bob@example.com | Where {($_.EventId -eq "RECEIVE") -and ($_.Recipients -eq "bob@example2.com")}

The above command will search the logs on the mailbox bob@example.com for received emails and they only select the emails sent to bob@example2.com.

For Exchange Online

The first thing you need to do is make your Remote PowerShell connection to Exchange Online.

Here is the command you want to run.https://technet.microsoft.com/en-us/library/jj200704%28v=exchg.160%29.aspx

Get-MessageTrace -RecipientAddress bob@example2.com -Status Delivered

Please let me know if you have any other questions.