I wanted to change the email address of a user in exchange server by powershell command which also needs to be updated on active directory

Athique Nihal 0 Reputation points
2023-03-22T09:39:31.2+00:00

I wanted to change the email address of a user in exchange server by powershell command which also needs to be updated on active directory

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,360 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Andy David - MVP 142.3K Reputation points MVP
    2023-03-22T11:53:03.1733333+00:00
    0 comments No comments

  2. Aholic Liang-MSFT 13,741 Reputation points Microsoft Vendor
    2023-03-23T09:48:33.9333333+00:00

    Hi @ Athique Nihal , Just wondering if there is another proxy address for this mailbox. If not ,you can refer to the following command to change directly:

    Set-Mailbox user2 -EmailAddressPolicyEnabled $False
    Set-Mailbox user2 -EmailAddresses $list  
    

    If the mailbox has other proxy addresses and needs to be retained, you cloud refer to the following script to modify the primary email address:

    
    Set-Mailbox user2 -EmailAddressPolicyEnabled $False
    
       $mb = Get-Mailbox  user2
       $newPrimaryMail = "user3@domain.com"
       $list = New-Object System.Collections.ArrayList
     
       foreach($address in $mb.EmailAddresses) {    
    
           if ($address.IsPrimaryAddress -eq "true") { 
                $address = "SMTP:" + $newPrimaryMail 
           } 
           else {
                $address = $address.ProxyAddressString 
           }
    
    
           $list.Add($address) 
       }
    
      Set-Mailbox user2 -EmailAddresses $list  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.