Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • 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
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • 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
  • PowerShell
  • Linux

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

March 17, 2024 Azure and Microsoft 365ExchangePowerShell

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
previous post
How to Change Computer Name (Hostname) in Windows
next post
Cannot Install Language Pack on Windows 10 or 11

Related Reading

View Windows Update History with PowerShell (CMD)

April 30, 2025

Uninstalling Windows Updates via CMD/PowerShell

April 18, 2025

Allowing Ping (ICMP Echo) Responses in Windows Firewall

April 15, 2025

How to Pause (Delay) Update Installation on Windows...

April 11, 2025

How to Write Logs to the Windows Event...

March 3, 2025

Leave a Comment Cancel Reply

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

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMware
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • 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
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 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
  • Fix: Microsoft Outlook Search Not Working on Windows 10/11
  • Blank Sign-in Screen in Office 365 Apps (Outlook, Teams, etc.)
  • Removing Built-in Teams Chat in Windows 11
Footer Logo

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


Back To Top