On Windows PowerShell and other admin-related topics

Add/remove e-mail addresses using Exchange Management Shell

Adding or removing e-mail addresses from mailboxes using the Exchange Management Shell in Exchange 2007/2010 isn`t a straightforward task, and are a common question in many Exchange/PowerShell-forums. PowerShell MVP Shay Levy has posted an excellent post on how to accomplish this using the Update-List cmdlet in Windows PowerShell 2.0.

To make this easier for Exchange administrators with less PowerShell experience, I decided to create two PowerShell advanced functions, which are available here.





As you can see, the Remove-EmailAddress accepts either –EmailAddress or –EmailDomain as parameters. Only one of the two can be specified. The –EmailDomain parameter removes all e-mail addresses containing the specified domain. Note that the PrimarySMTPAddress are never modified by either of the two functions. Also note that the functions require Windows PowerShell 2.0, since we are leveraging the Update-List cmdlet.

If you are running Exchange Server 2007 SP2, it is supported to install Windows PowerShell 2.0 (more info here).

To use the functions, you might use one of the following options:

Update 22.11.2010: Shay Levy has posted another blog-post on this topic: Managing email addresses in Exchange 2010. The technique used there are quite different (hash tables), so as you can see, PowerShell offers many different ways to accomplish the same task. What you choose is of course up to you.


November 14, 2010 - Posted by | Exchange Server 2007, Exchange Server 2010, Exchange Server management, Windows PowerShell |


  1. Brilliant, but how can i remove all email addresses fo a certian OU

    Comment by Warren | June 23, 2011 | Reply

  2. Get-Mailbox -OrganizationalUnit “ Users” | Remove-EmailAddress -EmailDomain

    tried this only seemed to do it for one users in the OU, the last one

    Comment by Warren | June 23, 2011 | Reply

    • Does it work with a foreeach-loop?
      Get-Mailbox -OrganizationalUnit “ Users” | Foreach-Object {Remove-EmailAddress -EmailDomain}

      Comment by Jan Egil Ring | June 23, 2011 | Reply

  3. Jan thanks for the reply, whan i use the for each it promps me for a Mailbox

    Comment by Warren | June 24, 2011 | Reply

    • What about this?
      Get-Mailbox -OrganizationalUnit “ Users” | Foreach-Object {Remove-EmailAddress -EmailDomain -Mailbox $_}

      Comment by Jan Egil Ring | June 26, 2011 | Reply

  4. Jan,

    getting closer I am now getting “Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.”


    Comment by Warren | June 29, 2011 | Reply

  5. I also had to change from mailbox to mailuser, depending on the type, but this makes sense, sorry to keep on but I am new to this powershell

    Comment by Warren | June 29, 2011 | Reply

  6. Thx for a nice script, didnt get the Define to work, but just imported the function in the active powershell window.

    Comment by Sigge | November 15, 2011 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: