none
Modify SMTP Address RRS feed

  • Question

  • Hi,

    We had several users left the company and we hide their mailboxes and change their primary smtp address to John.Smithzzz@abc.com. This is our standard process.

    Now most of the users are returned back we need to activate their mailboxes and change the primary smtp address to what they had before they left the company e.g. John.Smith@abc.com.

    I need to come up with a script to modify their smtp address as stated above for over 700 users. Any help will be greatly appreciated.

    I have come up with one script, but it removes all proxy address and only keeps primary smtp address i want. I want the script not to remove their other emailaddresses and just modify the one i want. We are using Exchange 2007 SP3 RU9.

    Import-CSV .\Users.csv | foreach {Set-Mailbox $_.email -Name $_.Name -DisplayName $_.DisplayName -Alias $_.Alias -EmailAddresses $_.mail -SamAccountName $_.SamAccountName -HiddenFromAddressListsEnabled $TRUE -EmailAddressPolicyEnable $False}


    Shahid

    Monday, January 14, 2013 3:53 AM

Answers

  • Hishahid,

    You can follow this to have a try:

    $mailboxes=get-mailbox -resultsize unlimited

    foreach($mailbox in $mailboxes)

    {

       for($i=($mailbox.EmailAddresses.count)-1; $i -ge 0; $i--)

      {
           $address=$mailbox.EmailAddresses[$i]
     
             $addressString=$address.addressString
     
             if($addressString -like "username@domain.com")
      
             {
                $mailbox.EmailAddresses.removeat($i)
              }

        }
     
    $mailbox|set-mailbox -EmailAddresses $mailbox.EmailAddresses

    }

    Thanks,

    Evan


    Evan Liu
    TechNet Community Support

    Tuesday, January 15, 2013 12:22 PM
    Moderator