Looking to remove SMTP address via command shell

Posted on 2011-10-28
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-
    LVL 3

    Expert Comment

    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.
    LVL 1

    Expert Comment

    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() )
    LVL 1

    Accepted Solution


    Author Closing Comment

    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

    Want to promote your upcoming event?

    Attending an event? Speaking at a conference? Or exhibiting at a tradeshow? Easily inform your contacts by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

    Join & Write a Comment

    Suggested Solutions

    Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
    In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
    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…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now