locked
2010 Remove SMTP from list of User but, keep current Primary RRS feed

  • Question

  • I am looking for a script to be able to remove all smtp staples from a list of user but keep the current primary stmp. 

    For example : UserX has 5 stmp U@doman.com,  k@domain.com, e@domain.com, top@domain.com, and r@domain.com.  U@domain.com is the primary domain.  I want to keep this one and get ride of the rest but only on select users.

    Anyone help me out. Thanks

    Thursday, December 27, 2012 7:26 PM

Answers

  • You can follow this to remove that:

    Use one txt file that contain all the users which you want to remove all the smtp addresses except primary smtp address.

    Then run this script to help you remove:

    $mailboxes=Get-content "C:\username.txt"| get-mailbox

    $mailboxes| foreach{

    $Emailaddresses=$_.Emailaddresses

    for($i=0; $i -lt $Emailaddresses.count; $i++){

    $Emailaddress=$Emailaddresses[$i]

    if($Emailaddress.IsPrimaryAddress -eq $true){

    $Emailaddresses=$Emailaddress
    }

    }

    set-mailbox $_ -Emailaddresses $Emailaddresses

    }

    Thanks,

    Evan


    Evan Liu
    TechNet Community Support

    • Marked as answer by Wally5605 Friday, December 28, 2012 9:57 PM
    Friday, December 28, 2012 10:23 AM
    Moderator

All replies

  • All of them are @domain.com so all are the primary domain.  One is the primary address.

    Addresses are automatically applied to mailboxes according to your e-mail address policy.  Configure e-mail address policy so that it is being applied to mailboxes the way you want.  You can then apply the e-mail address policy as changed to all mailboxes, but be warned that this is dangerous and may make changes you don't expect.  It's safer to remove addresses manually, but it's generally more time consuming, of course.


    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."

    Thursday, December 27, 2012 9:08 PM
  • You can follow this to remove that:

    Use one txt file that contain all the users which you want to remove all the smtp addresses except primary smtp address.

    Then run this script to help you remove:

    $mailboxes=Get-content "C:\username.txt"| get-mailbox

    $mailboxes| foreach{

    $Emailaddresses=$_.Emailaddresses

    for($i=0; $i -lt $Emailaddresses.count; $i++){

    $Emailaddress=$Emailaddresses[$i]

    if($Emailaddress.IsPrimaryAddress -eq $true){

    $Emailaddresses=$Emailaddress
    }

    }

    set-mailbox $_ -Emailaddresses $Emailaddresses

    }

    Thanks,

    Evan


    Evan Liu
    TechNet Community Support

    • Marked as answer by Wally5605 Friday, December 28, 2012 9:57 PM
    Friday, December 28, 2012 10:23 AM
    Moderator