skip to Main Content

Bulk remove secondary SMTP address with PowerShell

In the previous article, you learned how to list all SMTP addresses with PowerShell. We can see that the mailboxes have more than one SMTP address configured. These secondary SMTP addresses are also known as an alias address. In this article, you will learn how to bulk remove secondary SMTP address with PowerShell.

Prepare the remove SMTP address PowerShell script

Download the Remove-SMTP.ps1 script or copy and paste the below code in Notepad. Give it the name Remove-SMTP.ps1 and place it in the C:\scripts folder. Create a script folder if you don’t have one.

Change the @domain.com value to the domain that you want to remove from the mailboxes.

A couple of examples:

  • Example 1: Remove only SMTP addresses with the domain alitajran.com. Add “@alitajran.com“.
  • Example 2: Remove all SMTP addresses with the name tajran. Add “*tajran*“.

In my example, this is how it looks.

In the next step, you are going to run the script and see it in action.

Bulk remove secondary SMTP address PowerShell script

The -WhatIf parameter is added in the script. If you run the script, nothing will happen in the environment. You will get an output showing what will happen.

Run Exchange Management Shell as administrator. Go to the script path and run the Remove-SMTP.ps1 script. The script will go through all the mailboxes in the Exchange Organization.

In my example, all the SMTP addresses containing tajran will be removed in bulk. After running the script, confirm that these are the SMTP addresses that need to be removed.

Remove the -WhatIf parameter from the PowerShell script and rerun the script. The SMTP addresses are removed in bulk.

I hope that this helped you to remove unwanted SMTP addresses from the mailboxes in the Exchange organization.

Conclusion

In this article, you learned how to bulk remove secondary SMTP address with PowerShell. Download the Remove-SMTP PowerShell script. Add the domain that you like to remove and run the script. The script output will show which proxy addresses are removed. Don’t forget to test first with the -WhatIf parameter, as shown in the article.

Did you enjoy this article? You may also like Get Mailbox size of all users in Exchange with PowerShell. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect and IT Consultant. His specialism is designing and building complex enterprise environments. He started Information Technology at a very young age, and his goal is to teach and inspire others. Connect with ALI TAJRAN on social media. Read more »

This Post Has 0 Comments

Leave a Reply

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

Back To Top