Windows OS Hub
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux

 Windows OS Hub / Exchange / Get All SMTP (Email) Addresses Using PowerShell in Exchange

March 17, 2024

Get All SMTP (Email) Addresses Using PowerShell in Exchange

From time to time, you may need to export the full list of email addresses in your Exchange organization. In this article we will show how to get and export all the assigned SMTP addresses to a CSV file in Exchange Server or Microsoft 365 (Exchange Online) using PowerShell.

Connect to your Exchange organization:

  • You can use the Exchange Management Shell (EMS) module to manage on-premises Exchange Server, or you can connect to Exchange remotely from a regular PowerShell console;
  • Use the Exchange Online PowerShell module (EXO) to connect Microsoft 365 tenant.
    You can use certificate-based authentication to sign in to Exchange Online from within PowerShell.

To view all primary and additional SMTP addresses for a specific Exchange mailbox, run this command:

Get-Mailbox testmax |Select-Object DisplayName,PrimarySmtpAddress,EmailAddresses|fl

Exchange: list PrimarySmtpAddress and proxy addresses

  • The SMTP address in uppercase contains the primary email address
  • The lowercase smtp values are the secondary (alias) email addresses.
The proxyAddresses attribute is used to set the email delivery address in the on-premises Active Directory.

As you can see, a user is assigned several additional SMTP addresses, which are stored in the EmailAddresses string attribute. There may be other types of addresses in this attribute, so to get a list of all the SMTP addresses of a mailbox, run the command below:

Get-Mailbox testmax | Select-Object DisplayName,PrimarySmtpAddress, @{Name="SMTPAliases";Expression={($_.EmailAddresses | Where-Object { $_ -match "^smtp:" } | ForEach-Object {$_ -replace "smtp:",""}) -join "," }}

The following command displays all primary addresses and aliases for all user mailboxes and shared mailboxes in Exchange and exports the results to a CSV file:

Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress, @{Name="SMTPAliases";Expression={($_.EmailAddresses | Where-Object { $_ -match "^smtp:" } | ForEach-Object {$_ -replace "smtp:",""}) -join "," }} | Export-Csv "C:\PS\List-All-SMTP-Addresses.csv" -NoTypeInformation -Encoding UTF8

The Get-Mailbox cmdlet displays only information about users and shared mailboxes.

In Active Directory (or Azure AD), there may be other types of objects with SMTP addresses assigned (mail-enabled objects): distribution groups, contacts, and Microsoft 365 groups (Unified Groups in Entra ID). Use the Get-Recipient cmdlet to list the SMTP addresses of all the objects in an Exchange organization/tenant:

Get-Recipient -ResultSize Unlimited | Select-Object DisplayName, RecipientType, PrimarySmtpAddress, @{Name="SMTPAliases";Expression={($_.EmailAddresses | Where-Object { $_ -match "^smtp:" } | ForEach-Object {$_ -replace "smtp:",""}) -join "," }}

Export list of all Primary SMTP addresses and aliases to CSV file with PowerShell

In this case, we have a list of the SMTP addresses of all types of Exchange objects. To export only SMTP addresses of a specific object type, add the following parameter to the first cmdlet

Get-Recipient -ResultSize Unlimited -RecipientType your_object_type | …

Possible types of Exchange objects:

  • DynamicDistributionGroup
  • MailContact
  • MailNonUniversalGroup
  • MailUniversalDistributionGroup
  • MailUniversalSecurityGroup
  • MailUser
  • PublicFolder
  • UserMailbox
If you need to find Exchange objects with the same (duplicate) recipient SMTP address, run:

Get-Recipient -resultsize unlimited | where {$_.EmailAddresses -like "*[email protected]*"}

You can also get a flat list of SMTP addresses in Exchange:

Get-Recipient | Select-Object -ExpandProperty EmailAddresses | Where-Object { $_ -match "^smtp:" } | ForEach-Object { $_.Replace("smtp:", "").Replace("SMTP:", "") }

PowerShell: get unique sender email addresses

Unique SMTP addresses were also generated for the Microsoft Teams channel.

View the number of unique SMTP addresses in your Exchange organization:

Get-Recipient -ResultSize Unlimited | Select-Object -ExpandProperty EmailAddresses | Where-Object { $_ -match "^smtp:" }| measure-object

0 comment
1
Facebook Twitter Google + Pinterest
Azure and Microsoft 365ExchangePowerShell
previous post
How to Change Computer Name (Hostname) in Windows
next post
Cannot Install Language Pack on Windows 10 or 11

Related Reading

How to Block Sender Domain or Email Address...

March 17, 2024

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

March 17, 2024

Automatic Outlook User Profile Configuration with ZeroConfigExchange

May 21, 2024

Send Emails with Microsoft Graph API and PowerShell

March 17, 2024

Find Inactive (Unused) Distribution Lists in Exchange/Microsoft 365

March 17, 2024

Managing Inbox Rules in Exchange with PowerShell

March 15, 2024

Convert a User Mailbox to a Shared in...

March 15, 2024

Create a No-Reply Email Address in Exchange Server/Microsoft...

March 15, 2024

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Failed to Open the Group Policy Object on a Computer

    June 2, 2025
  • Remote Desktop Printing with RD Easy Print Redirection

    June 2, 2025
  • Disable the Lock Screen Widgets in Windows 11

    May 26, 2025
  • Configuring Windows Protected Print Mode (WPP)

    May 19, 2025
  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Outlook Keeps Asking for Password on Windows
  • Checking User Sign-in Logs in Entra ID (Microsoft 365)
  • How to Manually Configure Exchange or Microsoft 365 Account in Outlook 365/2019/2016
  • Search and Delete Emails from User Mailboxes on Exchange Server (Microsoft 365) with PowerShell
  • Configuring Password Policy in Microsoft Entra ID
  • Fix: Microsoft Outlook Search Not Working on Windows 10/11
  • Blank Sign-in Screen in Office 365 Apps (Outlook, Teams, etc.)
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top