skip to Main Content

Find email addresses with PowerShell

How to find email addresses with PowerShell? You like to know which SMTP email addresses/proxy addresses are configured in each mailbox. This can be a missing SMTP email address/proxy address. Sometimes the email address/proxy address is already set. In this article, you will learn how to find and list email addresses with PowerShell.

Find email addresses/proxy addresses

Before we start, is there a difference between the email address and proxy address? No, there is not. It depends only on where you look for the information. In Active Directory, it’s named proxy addresses. In Exchange Admin Center, it’s called email addresses.

You can configure more than one email address for the same mailbox. The additional addresses are called proxy addresses or secondary email addresses or alias addresses. A proxy address lets a user receive an email that’s sent to a different email address. Any email message sent to the user’s proxy address is delivered to their primary email address, known as the primary SMTP address or the default reply address.

You can use the following tools to find, add, or remove an email address for a mailbox:

  1. Exchange Admin Center (EAC)
  2. Active Directory Users and Computers (ADUC)
  3. Exchange Management Shell (EMS)

Let’s have a look at how to find the email addresses.

Exchange Admin Center

In the Exchange Admin Center, go to the properties of the mailbox. In our example, we are going to find the email addresses of the user Boris. Click email address on the left menu.

Find email addresses with PowerShell EAC email address

There are three email addresses configured:

  • 1x type SMTP with capital letters is the primary email address
  • 2x type smtp with small letters is the secondary email address/proxy address/alias email address.

How do we find the email addresses in Active Directory?

Active Directory

Start Active Directory Users and Computers (ADUC) and make sure to enable Advanced Features. If you don’t, you cannot see the Attribute Editor tab in the next step.

Find the object with a mailbox configured. In the Properties window, click the tab Attribute Editor. Double-click proxyAddresses in the list view.

Find email addresses with PowerShell Attribute Editor

The following addresses are configured for the user mailbox.

Find email addresses with PowerShell proxyAddresses

If you have many mailboxes, you will not open them one by one to find the email addresses. The best approach is to find the email address with PowerShell.

List all SMTP addresses with PowerShell

Run Exchange Management Shell as administrator. The first cmdlet will get a list of SMTP addresses. The second cmdlet will export the results to a CSV file in C:\temp. Don’t forget to create a temp folder on the C: drive or edit the export path.

[PS] C:\>Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress, @{Name="EmailAddresses";Expression={($_.EmailAddresses | Where-Object {$_ -clike "smtp*"} | ForEach-Object {$_ -replace "smtp:",""}) -join ","}} | Sort-Object DisplayName

DisplayName       PrimarySmtpAddress          EmailAddresses
-----------       ------------------          --------------
Administrator     Administrator@exoip.com     Administrator@exoip.local
Ali Tajran        Ali.Tajran@exoip.com
Amanda Morgan     Amanda.Morgan@exoip.com     Amanda.Morgan@alitajran.com, A.Morgan@exoip.com
Anna Welch        Anna.Welch@exoip.com
Benetiz Anees     Benetiz.Anees@exoip.com
Boris Campbell    Boris.Campbell@exoip.com    Boris.Campbell@contoso.com, Boris.Campbell@alitajran.com
Carl Kelly        Carl.Kelly@exoip.com
Christopher Payne Christopher.Payne@exoip.com


[PS] C:\>Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress, @{Name="EmailAddresses";Expression={($_.EmailAddresses | Where-Object {$_ -clike "smtp*"} | ForEach-Object {$_ -replace "smtp:",""}) -join ","}} | Sort-Object DisplayName | Export-CSV "C:\temp\List_SMTP_Addresses.csv" -NoTypeInformation -Encoding UTF8

Open the CSV file with Microsoft Excel or any other CSV file viewer/editor.

Find email addresses with PowerShell results CSV file

Find missing SMTP address with PowerShell

You like to get the mailboxes with a missing SMTP address. Detect mailboxes that are missing an SMTP address with PowerShell. Run Exchange Management Shell as administrator. Make use of the Get-Mailbox cmdlet. Find and list the mailboxes without the specific SMTP email address/proxy address.

You can see that the user Amanda and Boris are not showing in the results. That’s because they both have an email address with the domain @alitajran.com. The second cmdlet will export the results to a CSV file.

[PS] C:\>Get-Mailbox -ResultSize Unlimited -Filter {EmailAddresses -NotLike "*@alitajran.com"} | Select-Object DisplayName,PrimarySmtpAddress, @{Name="EmailAddresses";Expression={($_.EmailAddresses | Where-Object {$_ -clike "smtp*"} | ForEach-Object {$_ -replace "smtp:",""}) -join ","}} | Sort-Object DisplayName

DisplayName       PrimarySmtpAddress          EmailAddresses
-----------       ------------------          --------------
Administrator     Administrator@exoip.com     Administrator@exoip.local
Ali Tajran        Ali.Tajran@exoip.com
Anna Welch        Anna.Welch@exoip.com
Benetiz Anees     Benetiz.Anees@exoip.com
Carl Kelly        Carl.Kelly@exoip.com
Christopher Payne Christopher.Payne@exoip.com


[PS] C:\>Get-Mailbox -ResultSize Unlimited -Filter {EmailAddresses -NotLike "*@alitajran.com"} | Select-Object DisplayName,PrimarySmtpAddress, @{Name="EmailAddresses";Expression={($_.EmailAddresses | Where-Object {$_ -clike "smtp*"} | ForEach-Object {$_ -replace "smtp:",""}) -join ","}} | Sort-Object DisplayName | Export-CSV "C:\temp\Missing_SMTP_Addresses.csv" -NoTypeInformation -Encoding UTF8

Results after opening the exported CSV file in Microsoft Excel.

Find email addresses with PowerShell results CSV file missing SMTP

Find specific SMTP address with PowerShell

Do you like to know how to find the mailboxes with a specific SMTP email address/proxy address? Change the comparison operator from -NotLike to -Like. The following mailboxes do have an email with the domain @alitajran.com configured as SMTP.

[PS] C:\>Get-Mailbox -ResultSize Unlimited -Filter {EmailAddresses -Like "*@alitajran.com"} | Select-Object DisplayName,PrimarySmtpAddress, @{Name="EmailAddresses";Expression={($_.EmailAddresses | Where-Object {$_ -clike "smtp*"} | ForEach-Object {$_ -replace "smtp:",""}) -join ","}} | Sort-Object DisplayName

DisplayName    PrimarySmtpAddress       EmailAddresses
-----------    ------------------       --------------
Amanda Morgan  Amanda.Morgan@exoip.com  Amanda.Morgan@alitajran.com, A.Morgan@exoip.com
Boris Campbell Boris.Campbell@exoip.com Boris.Campbell@contoso.com, Boris.Campbell@alitajran.com


[PS] C:\>Get-Mailbox -ResultSize Unlimited -Filter {EmailAddresses -Like "*@alitajran.com"} | Select-Object DisplayName,PrimarySmtpAddress, @{Name="EmailAddresses";Expression={($_.EmailAddresses | Where-Object {$_ -clike "smtp*"} | ForEach-Object {$_ -replace "smtp:",""}) -join ","}} | Sort-Object DisplayName | Export-CSV "C:\temp\Specific_SMTP_Addresses.csv" -NoTypeInformation -Encoding UTF8

The results in Microsoft Excel after opening the exported CSV file.

I hope it helped you to find the mailboxes with a specific email address/proxy address configured. In the next article, we are going to bulk add SMTP proxy address to the mailboxes.

Keep on reading: Add email address to list of names in Excel »

Conclusion

In this article, you learned how to find email addresses with PowerShell. Run the cmdlets as shown in the article to get a list of all SMTP email addresses in PowerShell, a list with missing SMTP addresses, or a list with specific SMTP addresses. Export the results to a CSV file and open it with your favorite CSV viewer/editor.

Did you enjoy this article? You may also like Complete mailbox migration with bad items. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

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