locked
How to: Removing x400 addresses (via Powershell)

    Question

  • Hi there

    we have a few accounts and all of them have x400 addresses. now we'd like to remove them from the users.

    what i've already done: i removed the x400 entry on the "default e-mail address policy" but on all user accounts the x400 still resists.

    question: how can i remove the x400 address for all the user accounts?

    maybe there is something to do with EMS? thanks for your input,

     

    uerueluem

    Monday, August 16, 2010 6:57 AM

Answers

  • The following Script worked successfully
     

    foreach ($mbx in (get-mailbox )){
    $addrs = $mbx.emailaddresses |? {$_.prefixstring -ne "x400"}
    set-mailbox $mbx -emailaddresses $addrs -whatif
    }
    


    #to execute the script, remove the "-whatif", otherwise it's just a test

    • Marked as answer by uerueluem Wednesday, July 27, 2011 3:14 PM
    Wednesday, July 27, 2011 3:14 PM

All replies

  • Please check whether the below article can help you:
    http://support.microsoft.com/kb/318774.


    Dinesh
    Monday, August 16, 2010 1:35 PM
  • In EMS, you can use a powershell script like this:

    foreach ($mbx in (get-mailbox -resutlsize unlimited){

    $addrs = $mbx.emailaddresses |? {$_.prefixstring -ne "x400"}

    set-mailbox $mbx -emailaddresses $addrs -whatif

    }

    Run that, and if the results look right, remove the -whatif switch from the set-mailbox and re-run it to do the updates.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    • Proposed as answer by Alan.Gim Tuesday, August 17, 2010 4:33 AM
    • Unproposed as answer by uerueluem Thursday, August 19, 2010 7:14 AM
    Monday, August 16, 2010 1:52 PM
  • I have changed the script a littlebit because it wasn't working as is.

    Now it looks like that:

     

    foreach ($mbx in get-mailbox){

    $addrs = $mbx.emailaddresses |? {$_.prefixstring -ne "x400"}

    set-mailbox $mbx -emailaddresses $addrs

    }

     

    but even if I changed the script, it wont remove the x400 records from my Users :-(

     

    thanks to mjolinor

    • Edited by uerueluem Thursday, August 19, 2010 7:14 AM
    Wednesday, August 18, 2010 2:23 PM
  • i also found another way to do it, but as the script also the program ADModify does not remove the x400 addresses. :(

    http://msexchangetips.blogspot.com/ --> Exchange: Bulk Remove X.400 Address Using Admodify

    Wednesday, August 18, 2010 3:03 PM
  • Mjolinor missed a “)” in the first line

    foreach ($mbx in (get-mailbox -resutlsize unlimited)){


    James Luo
    TechNet Subscriber Support (http://technet.microsoft.com/en-us/subscriptions/ms788697.aspx)
    If you have any feedback on our support, please contact tngfb@microsoft.com
    Thursday, August 19, 2010 1:32 AM
  • I also misspelled -resultsize :(

     


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    • Proposed as answer by Alan.Gim Tuesday, August 24, 2010 1:22 AM
    • Marked as answer by Alan.Gim Thursday, August 26, 2010 1:59 AM
    • Unmarked as answer by uerueluem Wednesday, July 27, 2011 1:31 PM
    • Unproposed as answer by uerueluem Wednesday, July 27, 2011 1:31 PM
    Thursday, August 19, 2010 2:02 AM
  • How's the result after using the modified script from mjolinor?

    I have tested it in the lab


    James Luo
    TechNet Subscriber Support (http://technet.microsoft.com/en-us/subscriptions/ms788697.aspx)
    If you have any feedback on our support, please contact tngfb@microsoft.com
    Friday, August 20, 2010 1:18 AM
  • The following Script worked successfully
     

    foreach ($mbx in (get-mailbox )){
    $addrs = $mbx.emailaddresses |? {$_.prefixstring -ne "x400"}
    set-mailbox $mbx -emailaddresses $addrs -whatif
    }
    


    #to execute the script, remove the "-whatif", otherwise it's just a test

    • Marked as answer by uerueluem Wednesday, July 27, 2011 3:14 PM
    Wednesday, July 27, 2011 3:14 PM
  • The following Script worked successfully

    foreach ($mbx in (get-mailbox )){
    $addrs = $mbx.emailaddresses |? {$_.prefixstring -ne "x400"}
    set-mailbox $mbx -emailaddresses $addrs -whatif
    }
    


    #to execute the script, remove the "-whatif", otherwise it's just a test

    works for x500 thx very much
    • Edited by moshsrv Monday, January 23, 2012 3:31 PM
    Monday, January 23, 2012 3:31 PM
  • Can this be done using this method for Distribution Groups?
    Friday, May 18, 2012 10:56 AM
  • Figured it out for Distribution Groups;

    To test use this command in EMS;

    foreach ($mbx in (Get-DistributionGroup -resultsize unlimited)){
    $addrs = $mbx.emailaddresses |? {$_.prefixstring -ne "x400"}
    Set-DistributionGroup $mbx -emailaddresses $addrs -whatif
    }

    Then to remove X400 addresses use this command in EMS;

    foreach ($mbx in (Get-DistributionGroup -resultsize unlimited)){
    $addrs = $mbx.emailaddresses |? {$_.prefixstring -ne "x400"}
    Set-DistributionGroup $mbx -emailaddresses $addrs
    }


    • Proposed as answer by Hector Ventura Wednesday, February 27, 2013 7:03 PM
    • Unproposed as answer by Hector Ventura Wednesday, February 27, 2013 7:03 PM
    • Proposed as answer by mvalpreda Monday, May 6, 2013 11:42 PM
    Friday, May 18, 2012 5:02 PM