how to bulk remove an email alias in Exchange 2016?

Sophia 356 Reputation points

Hello guys/gals,

How would should I go about removing an email address alias for all of my mailboxes?

Currently mailboxes have the following: .com
smtp:user1@xyz .com (I want to remove this alias)


Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,228 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,380 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yuki Sun-MSFT 40,871 Reputation points

    Hi @Safs-3080,

    Based on my research and test, the following scripts can be used to bulk remove a secondary smtp email address.

    You can copy and paste the below code in Notepad, save it as a.ps1 file and give it a name such as "Remove-SMTP.ps1", put it in a folder like C:\scripts, then you would be able to bulk remove all SMTP addresses with the domain by running the script. Before running the script, it's suggested to add "-WhatIf" after "Set-Mailbox $Mailbox -EmailAddresses @{remove = $_ } " to take a look at what will happen.

    Start-Transcript -Path C:\temp\Remove-SMTP-Address.log -Append  
    $Mailboxes = Get-Mailbox -ResultSize Unlimited  
    foreach ($Mailbox in $Mailboxes) {  
            $Mailbox.EmailAddresses | Where-Object { $_.AddressString -like "*" } | ForEach-Object {  
            Set-Mailbox $Mailbox -EmailAddresses @{remove = $_ }   
            Write-Host "Removing $_ from $Mailbox Mailbox" -ForegroundColor Green  



    For more details, hopefully you can find the article below helpful:
    Bulk remove secondary SMTP address with PowerShell
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.