Looking to remove SMTP address via command shell

Posted on 2011-10-28
Medium Priority
Last Modified: 2012-05-12
OK here is the deal, i am looking for a SIMPLE command one line to just remove an smtp nothing fancy:
Simply put i want to pick 1 account JDoe and remove an alias that is not his primary with a command line
Question by:Wdntulk2no-
  • 2

Expert Comment

ID: 37048118
Are you looking to remove the alias or an SMTP address?

Using the Exchange Shell?

set-mailbox "username" -Alias <value>

for the SMTP address, it would depend on what you currently have listed and if you are using x400 addresses still or not. If there are multiple addresses that you want to keep, you'll have to list each one here seperated by commas.

set-mailbox "username" -EmailAddresses {SMTP:email@address}

I don't believe you can do any of this from just the standard command line without calling a script.

Expert Comment

ID: 37048162
Here you go
Get-Mailbox | foreach {
for ($i=$_.EmailAddresses.Count;$i -ge 0; $i--)
$address = $_.EmailAddresses[$i]
if ($address.SmtpAddress -like "*@target.local" )
Write-host("Remove smtp adress: " + $address.AddressString.ToString() )

Accepted Solution

Ajit663 earned 1500 total points
ID: 37048171

Author Closing Comment

ID: 37179155
Unable to verify this solution. I no longer have access to this server so i cannot be fore sure if it would work or not.

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
Stellar Exchange Toolkit: this 5 in 1 toolkit comes loaded with mega-software tool. Here’s an introduction to tools’ usage and advantages:
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
how to add IIS SMTP to handle application/Scanner relays into office 365.
Suggested Courses
Course of the Month17 days, 1 hour left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question