How to remove the SMTP address for a secondary domain from all Exchange mailboxes?Exchange 2003 SP2/2007: Address space ignored in SMTP ConnectorHow can I add subdomains of default accepted domain of Exchange 2010exchange 2007 with two accepted domains, send mailEmails sent from Coldfusion using the same SMTP/Exchange server works from one machine but fails for anotherHide server ip from email headerScript to remove Exchange 2010 AutoMapping for all mailboxesSMTP routing with EDGE servers for Exchange 2010Exchange 2010: Send emails via STMP with custom From address to outside the domainExchange 2003 SMTP does not receive RCPT from senderHow can I route messages from Intermedia Exchange to Office 365 if they share the same domain?

Why don't countries like Japan just print more money?

Minimum distance between holes in inner tube

How much will studying magic in an academy cost?

How would modern naval warfare have to have developed differently for battleships to still be relevant in the 21st century?

Suggested order for Amazon Prime Doctor Who series

How do I professionally let my manager know I'll quit over smoking in the office?

Can you find x?

How to get cool night-vision without lame drawbacks?

Unusual mail headers, evidence of an attempted attack. Have I been pwned?

Why do textbooks often include the solutions to odd or even numbered problems but not both?

Old sci-fi story: radiation mutated the animals, a boy loses a limb, but it's okay because "humans used to do great with only two arms"

When to remove insignificant variables?

Do I have any obligations to my PhD supervisor's requests after I have graduated?

Do I have to explain the mechanical superiority of the player-character within the fiction of the game?

How to colour a table with opaque colour such that no text and no lines are visible?

Employer wants to use my work email account after I quit

What did River say when she woke from her proto-comatose state?

Helping ease my back pain when I'm studying 13 hours everyday, even weekends

Who are the remaining King/Queenslayers?

How is hair tissue mineral analysis performed?

Inaccessible base class despite friendship

Is a single radon-daughter atom in air a solid?

Hot coffee brewing solutions for deep woods camping

Why use cross notes in sheet music for hip hop tracks?



How to remove the SMTP address for a secondary domain from all Exchange mailboxes?


Exchange 2003 SP2/2007: Address space ignored in SMTP ConnectorHow can I add subdomains of default accepted domain of Exchange 2010exchange 2007 with two accepted domains, send mailEmails sent from Coldfusion using the same SMTP/Exchange server works from one machine but fails for anotherHide server ip from email headerScript to remove Exchange 2010 AutoMapping for all mailboxesSMTP routing with EDGE servers for Exchange 2010Exchange 2010: Send emails via STMP with custom From address to outside the domainExchange 2003 SMTP does not receive RCPT from senderHow can I route messages from Intermedia Exchange to Office 365 if they share the same domain?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








4















I have an Exchange server which used to manage multiple SMTP domains; now it only has to manage one.



I have already removed the secondary domain from all address policies; I need to remove all SMTP addresses referencing it.



All users have their primary SMTP address set to use the primary domain; but almost all of them have another address using the secondary domain. They also have many other different addesses: the SIP one used for lync, and one or more X500 ones derived from previous migrations. These should not be touched at all.



How can I remove all those secondary SMTP addresses without affecting anything else?










share|improve this question

















  • 2





    ADModify.NET - admodify.codeplex.com

    – joeqwerty
    Dec 9 '13 at 17:54











  • +1 for ADModify.NET. It will do this easily...and can even make sure the "primary SMTP address/reply to" is set if necessary.

    – TheCleaner
    Dec 9 '13 at 19:17


















4















I have an Exchange server which used to manage multiple SMTP domains; now it only has to manage one.



I have already removed the secondary domain from all address policies; I need to remove all SMTP addresses referencing it.



All users have their primary SMTP address set to use the primary domain; but almost all of them have another address using the secondary domain. They also have many other different addesses: the SIP one used for lync, and one or more X500 ones derived from previous migrations. These should not be touched at all.



How can I remove all those secondary SMTP addresses without affecting anything else?










share|improve this question

















  • 2





    ADModify.NET - admodify.codeplex.com

    – joeqwerty
    Dec 9 '13 at 17:54











  • +1 for ADModify.NET. It will do this easily...and can even make sure the "primary SMTP address/reply to" is set if necessary.

    – TheCleaner
    Dec 9 '13 at 19:17














4












4








4


1






I have an Exchange server which used to manage multiple SMTP domains; now it only has to manage one.



I have already removed the secondary domain from all address policies; I need to remove all SMTP addresses referencing it.



All users have their primary SMTP address set to use the primary domain; but almost all of them have another address using the secondary domain. They also have many other different addesses: the SIP one used for lync, and one or more X500 ones derived from previous migrations. These should not be touched at all.



How can I remove all those secondary SMTP addresses without affecting anything else?










share|improve this question














I have an Exchange server which used to manage multiple SMTP domains; now it only has to manage one.



I have already removed the secondary domain from all address policies; I need to remove all SMTP addresses referencing it.



All users have their primary SMTP address set to use the primary domain; but almost all of them have another address using the secondary domain. They also have many other different addesses: the SIP one used for lync, and one or more X500 ones derived from previous migrations. These should not be touched at all.



How can I remove all those secondary SMTP addresses without affecting anything else?







exchange exchange-2010 smtp powershell






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 9 '13 at 17:38









MassimoMassimo

53.6k45172288




53.6k45172288







  • 2





    ADModify.NET - admodify.codeplex.com

    – joeqwerty
    Dec 9 '13 at 17:54











  • +1 for ADModify.NET. It will do this easily...and can even make sure the "primary SMTP address/reply to" is set if necessary.

    – TheCleaner
    Dec 9 '13 at 19:17













  • 2





    ADModify.NET - admodify.codeplex.com

    – joeqwerty
    Dec 9 '13 at 17:54











  • +1 for ADModify.NET. It will do this easily...and can even make sure the "primary SMTP address/reply to" is set if necessary.

    – TheCleaner
    Dec 9 '13 at 19:17








2




2





ADModify.NET - admodify.codeplex.com

– joeqwerty
Dec 9 '13 at 17:54





ADModify.NET - admodify.codeplex.com

– joeqwerty
Dec 9 '13 at 17:54













+1 for ADModify.NET. It will do this easily...and can even make sure the "primary SMTP address/reply to" is set if necessary.

– TheCleaner
Dec 9 '13 at 19:17






+1 for ADModify.NET. It will do this easily...and can even make sure the "primary SMTP address/reply to" is set if necessary.

– TheCleaner
Dec 9 '13 at 19:17











2 Answers
2






active

oldest

votes


















3














Test this in a lab and/or on a small set of test users before hitting production with this please.



$SMTPDomainToRemove = "@OldDomain.com"
$AllUsers = Get-ADUser -Filter * -Properties proxyAddresses
Foreach($usr In $AllUsers)

$NewAddressList = @()
$OldAddressList = $usr.proxyAddresses
Foreach($addr In $OldAddressList)

If(!($addr -Match $SMTPDomainToRemove))

$NewAddressList += $addr


If($NewAddressList.Count -GT 0)

Set-ADUser $usr -Replace @ 'proxyAddresses' = $NewAddressList




The idea is that we're taking the proxyAddresses address list of each user, stripping out the ones that have the old domain name in them, and then replacing the address list with the new, updated one that does not contain references to the old domain name.



http://blogs.technet.com/b/exchange/archive/2005/01/10/350132.aspx




E-Mail Address Attributes



Exchange stores and uses information about the e-mail addresses of a
recipient in the following attributes: proxyAddresses



This is the main attribute where e-mail address information is kept.
When you open the properties of a recipient in Outlook and look at the
"E-mail Addresses" tab, you are looking at this attribute. This is a
multi-valued string containing all the addresses that represent the
recipient. Each value must have the following format: type:address



For example: SMTP:nospam@online.microsoft.com



When the type is in uppercase letters, the address is considered to be
the primary address of that type and it is used as the default reply
address of that recipient. When the type is in lowercase letters, the
address is considered a secondary address and is used to resolve
addresses during e-mail delivery, allowing the same recipient to
receive e-mails directed to different e-mail addresses.







share|improve this answer




















  • 1





    Well, my primary address is olddomain.com@newdomain.com and now I don't have to mind my inbox anymore, thanks! :D

    – Mathias R. Jessen
    Dec 9 '13 at 21:15











  • OK... How about $addr.ToLower().Trim().EndsWith($SMTPDomainToRemove.ToLower().Trim())... better? :)

    – Ryan Ries
    Dec 9 '13 at 21:21






  • 1





    Or even just a well-placed @ sign... ;)

    – Ryan Ries
    Dec 9 '13 at 21:31


















3














Found it!



$domain = 'olddomain.com'

$mbxs = (Get-Mailbox -ResultSize Unlimited | where $_.EmailAddresses -like ('*@' + $domain) )

foreach ($mbx in $mbxs)

$addresses = $mbx.EmailAddresses
$address = ($addresses





share|improve this answer



























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "2"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f560175%2fhow-to-remove-the-smtp-address-for-a-secondary-domain-from-all-exchange-mailboxe%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    Test this in a lab and/or on a small set of test users before hitting production with this please.



    $SMTPDomainToRemove = "@OldDomain.com"
    $AllUsers = Get-ADUser -Filter * -Properties proxyAddresses
    Foreach($usr In $AllUsers)

    $NewAddressList = @()
    $OldAddressList = $usr.proxyAddresses
    Foreach($addr In $OldAddressList)

    If(!($addr -Match $SMTPDomainToRemove))

    $NewAddressList += $addr


    If($NewAddressList.Count -GT 0)

    Set-ADUser $usr -Replace @ 'proxyAddresses' = $NewAddressList




    The idea is that we're taking the proxyAddresses address list of each user, stripping out the ones that have the old domain name in them, and then replacing the address list with the new, updated one that does not contain references to the old domain name.



    http://blogs.technet.com/b/exchange/archive/2005/01/10/350132.aspx




    E-Mail Address Attributes



    Exchange stores and uses information about the e-mail addresses of a
    recipient in the following attributes: proxyAddresses



    This is the main attribute where e-mail address information is kept.
    When you open the properties of a recipient in Outlook and look at the
    "E-mail Addresses" tab, you are looking at this attribute. This is a
    multi-valued string containing all the addresses that represent the
    recipient. Each value must have the following format: type:address



    For example: SMTP:nospam@online.microsoft.com



    When the type is in uppercase letters, the address is considered to be
    the primary address of that type and it is used as the default reply
    address of that recipient. When the type is in lowercase letters, the
    address is considered a secondary address and is used to resolve
    addresses during e-mail delivery, allowing the same recipient to
    receive e-mails directed to different e-mail addresses.







    share|improve this answer




















    • 1





      Well, my primary address is olddomain.com@newdomain.com and now I don't have to mind my inbox anymore, thanks! :D

      – Mathias R. Jessen
      Dec 9 '13 at 21:15











    • OK... How about $addr.ToLower().Trim().EndsWith($SMTPDomainToRemove.ToLower().Trim())... better? :)

      – Ryan Ries
      Dec 9 '13 at 21:21






    • 1





      Or even just a well-placed @ sign... ;)

      – Ryan Ries
      Dec 9 '13 at 21:31















    3














    Test this in a lab and/or on a small set of test users before hitting production with this please.



    $SMTPDomainToRemove = "@OldDomain.com"
    $AllUsers = Get-ADUser -Filter * -Properties proxyAddresses
    Foreach($usr In $AllUsers)

    $NewAddressList = @()
    $OldAddressList = $usr.proxyAddresses
    Foreach($addr In $OldAddressList)

    If(!($addr -Match $SMTPDomainToRemove))

    $NewAddressList += $addr


    If($NewAddressList.Count -GT 0)

    Set-ADUser $usr -Replace @ 'proxyAddresses' = $NewAddressList




    The idea is that we're taking the proxyAddresses address list of each user, stripping out the ones that have the old domain name in them, and then replacing the address list with the new, updated one that does not contain references to the old domain name.



    http://blogs.technet.com/b/exchange/archive/2005/01/10/350132.aspx




    E-Mail Address Attributes



    Exchange stores and uses information about the e-mail addresses of a
    recipient in the following attributes: proxyAddresses



    This is the main attribute where e-mail address information is kept.
    When you open the properties of a recipient in Outlook and look at the
    "E-mail Addresses" tab, you are looking at this attribute. This is a
    multi-valued string containing all the addresses that represent the
    recipient. Each value must have the following format: type:address



    For example: SMTP:nospam@online.microsoft.com



    When the type is in uppercase letters, the address is considered to be
    the primary address of that type and it is used as the default reply
    address of that recipient. When the type is in lowercase letters, the
    address is considered a secondary address and is used to resolve
    addresses during e-mail delivery, allowing the same recipient to
    receive e-mails directed to different e-mail addresses.







    share|improve this answer




















    • 1





      Well, my primary address is olddomain.com@newdomain.com and now I don't have to mind my inbox anymore, thanks! :D

      – Mathias R. Jessen
      Dec 9 '13 at 21:15











    • OK... How about $addr.ToLower().Trim().EndsWith($SMTPDomainToRemove.ToLower().Trim())... better? :)

      – Ryan Ries
      Dec 9 '13 at 21:21






    • 1





      Or even just a well-placed @ sign... ;)

      – Ryan Ries
      Dec 9 '13 at 21:31













    3












    3








    3







    Test this in a lab and/or on a small set of test users before hitting production with this please.



    $SMTPDomainToRemove = "@OldDomain.com"
    $AllUsers = Get-ADUser -Filter * -Properties proxyAddresses
    Foreach($usr In $AllUsers)

    $NewAddressList = @()
    $OldAddressList = $usr.proxyAddresses
    Foreach($addr In $OldAddressList)

    If(!($addr -Match $SMTPDomainToRemove))

    $NewAddressList += $addr


    If($NewAddressList.Count -GT 0)

    Set-ADUser $usr -Replace @ 'proxyAddresses' = $NewAddressList




    The idea is that we're taking the proxyAddresses address list of each user, stripping out the ones that have the old domain name in them, and then replacing the address list with the new, updated one that does not contain references to the old domain name.



    http://blogs.technet.com/b/exchange/archive/2005/01/10/350132.aspx




    E-Mail Address Attributes



    Exchange stores and uses information about the e-mail addresses of a
    recipient in the following attributes: proxyAddresses



    This is the main attribute where e-mail address information is kept.
    When you open the properties of a recipient in Outlook and look at the
    "E-mail Addresses" tab, you are looking at this attribute. This is a
    multi-valued string containing all the addresses that represent the
    recipient. Each value must have the following format: type:address



    For example: SMTP:nospam@online.microsoft.com



    When the type is in uppercase letters, the address is considered to be
    the primary address of that type and it is used as the default reply
    address of that recipient. When the type is in lowercase letters, the
    address is considered a secondary address and is used to resolve
    addresses during e-mail delivery, allowing the same recipient to
    receive e-mails directed to different e-mail addresses.







    share|improve this answer















    Test this in a lab and/or on a small set of test users before hitting production with this please.



    $SMTPDomainToRemove = "@OldDomain.com"
    $AllUsers = Get-ADUser -Filter * -Properties proxyAddresses
    Foreach($usr In $AllUsers)

    $NewAddressList = @()
    $OldAddressList = $usr.proxyAddresses
    Foreach($addr In $OldAddressList)

    If(!($addr -Match $SMTPDomainToRemove))

    $NewAddressList += $addr


    If($NewAddressList.Count -GT 0)

    Set-ADUser $usr -Replace @ 'proxyAddresses' = $NewAddressList




    The idea is that we're taking the proxyAddresses address list of each user, stripping out the ones that have the old domain name in them, and then replacing the address list with the new, updated one that does not contain references to the old domain name.



    http://blogs.technet.com/b/exchange/archive/2005/01/10/350132.aspx




    E-Mail Address Attributes



    Exchange stores and uses information about the e-mail addresses of a
    recipient in the following attributes: proxyAddresses



    This is the main attribute where e-mail address information is kept.
    When you open the properties of a recipient in Outlook and look at the
    "E-mail Addresses" tab, you are looking at this attribute. This is a
    multi-valued string containing all the addresses that represent the
    recipient. Each value must have the following format: type:address



    For example: SMTP:nospam@online.microsoft.com



    When the type is in uppercase letters, the address is considered to be
    the primary address of that type and it is used as the default reply
    address of that recipient. When the type is in lowercase letters, the
    address is considered a secondary address and is used to resolve
    addresses during e-mail delivery, allowing the same recipient to
    receive e-mails directed to different e-mail addresses.








    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 9 '13 at 21:30

























    answered Dec 9 '13 at 18:10









    Ryan RiesRyan Ries

    50.9k8118181




    50.9k8118181







    • 1





      Well, my primary address is olddomain.com@newdomain.com and now I don't have to mind my inbox anymore, thanks! :D

      – Mathias R. Jessen
      Dec 9 '13 at 21:15











    • OK... How about $addr.ToLower().Trim().EndsWith($SMTPDomainToRemove.ToLower().Trim())... better? :)

      – Ryan Ries
      Dec 9 '13 at 21:21






    • 1





      Or even just a well-placed @ sign... ;)

      – Ryan Ries
      Dec 9 '13 at 21:31












    • 1





      Well, my primary address is olddomain.com@newdomain.com and now I don't have to mind my inbox anymore, thanks! :D

      – Mathias R. Jessen
      Dec 9 '13 at 21:15











    • OK... How about $addr.ToLower().Trim().EndsWith($SMTPDomainToRemove.ToLower().Trim())... better? :)

      – Ryan Ries
      Dec 9 '13 at 21:21






    • 1





      Or even just a well-placed @ sign... ;)

      – Ryan Ries
      Dec 9 '13 at 21:31







    1




    1





    Well, my primary address is olddomain.com@newdomain.com and now I don't have to mind my inbox anymore, thanks! :D

    – Mathias R. Jessen
    Dec 9 '13 at 21:15





    Well, my primary address is olddomain.com@newdomain.com and now I don't have to mind my inbox anymore, thanks! :D

    – Mathias R. Jessen
    Dec 9 '13 at 21:15













    OK... How about $addr.ToLower().Trim().EndsWith($SMTPDomainToRemove.ToLower().Trim())... better? :)

    – Ryan Ries
    Dec 9 '13 at 21:21





    OK... How about $addr.ToLower().Trim().EndsWith($SMTPDomainToRemove.ToLower().Trim())... better? :)

    – Ryan Ries
    Dec 9 '13 at 21:21




    1




    1





    Or even just a well-placed @ sign... ;)

    – Ryan Ries
    Dec 9 '13 at 21:31





    Or even just a well-placed @ sign... ;)

    – Ryan Ries
    Dec 9 '13 at 21:31













    3














    Found it!



    $domain = 'olddomain.com'

    $mbxs = (Get-Mailbox -ResultSize Unlimited | where $_.EmailAddresses -like ('*@' + $domain) )

    foreach ($mbx in $mbxs)

    $addresses = $mbx.EmailAddresses
    $address = ($addresses





    share|improve this answer





























      3














      Found it!



      $domain = 'olddomain.com'

      $mbxs = (Get-Mailbox -ResultSize Unlimited | where $_.EmailAddresses -like ('*@' + $domain) )

      foreach ($mbx in $mbxs)

      $addresses = $mbx.EmailAddresses
      $address = ($addresses





      share|improve this answer



























        3












        3








        3







        Found it!



        $domain = 'olddomain.com'

        $mbxs = (Get-Mailbox -ResultSize Unlimited | where $_.EmailAddresses -like ('*@' + $domain) )

        foreach ($mbx in $mbxs)

        $addresses = $mbx.EmailAddresses
        $address = ($addresses





        share|improve this answer















        Found it!



        $domain = 'olddomain.com'

        $mbxs = (Get-Mailbox -ResultSize Unlimited | where $_.EmailAddresses -like ('*@' + $domain) )

        foreach ($mbx in $mbxs)

        $addresses = $mbx.EmailAddresses
        $address = ($addresses






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jun 5 at 19:15

























        answered Dec 9 '13 at 18:27









        MassimoMassimo

        53.6k45172288




        53.6k45172288



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Server Fault!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f560175%2fhow-to-remove-the-smtp-address-for-a-secondary-domain-from-all-exchange-mailboxe%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

            Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

            What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company