Office 365: How to change primary email address when using Dirsync,AADSync or Azure Active Directory Connect

It is simple to change the Primary Email Address of an Office 365 user when your tenant is not being synced to your on-premises active directory, but if you are syncing to Office 365 with any of the following tools:

  • Windows Azure Active Directory Sync (DirSync)
  • Azure AD Sync (AADSync)
  • Azure Active Directory Connect

Then you will be unable to change any of email addresses associated with that account, and you will get the following error:

The operation on mailbox “Mailbox” failed because it’s out of the current user’s write scope. The action ‘Set-Mailbox’, ‘EmailAddresses’, can’t be performed on the object ‘Mailbox’ because the object is being synchronized from your on-premises organization. This action should be performed on the object in your on-premises organization.

Image showing error from Office 365 when trying to change the primary SMTP address for an account that is synced to a local active directory.

How to change the Primary Email Address for an Office 365 account using Active Directory Users and Computers

  1. Open Active Directory Users and Computers
  2. Ensure you have “Advanced Features” enabled from the view menu:
    Image showing how to enable the "Advanced Features" in Active Directory Users and Computers
  3. Double click on the user that you want to edit the email addresses for.
  4. Go to the “Attribute Editor” tab.
  5. Go to the “proxyAddresses” attribute and click edit.
  6. Edit the email addresses as per your requirements. Note that the primary address (which is the address that the user will send emails from) is in uppercase “SMTP”.
    Image showing how to edit the proxyaddresses attribute for an Office 365 user synced to local active directory.

 

How to change the Primary Email Address for an Office 365 account using Powershell

You can perform the same operation using Windows Powershell, the basic syntax is like this:

  1. Set-ADUser paulie -Add @{ProxyAddresses=“SMTP:primaryaddress@tachytelic.net”}

The problem with running this command is that you may already have a primary SMTP address set and this will not stop you from adding another one. So first of all run:

  1. get-aduser paulie -properties proxyaddresses | Select-Object Name,ProxyAddresses |fl

This will show you all the current proxy addresses for this user. If you want to remove an existing proxy address you can use:

  1. Set-ADUser paulie -Remove @{ProxyAddresses=“smtp:paulietest@tachytelic.net”}

It is possible neither of the above methods will work if you have never had Exchange installed locally, as the users will not have these attributes. You can follow the instructions on this pagein order to get the attributes enabled for your users.

sourse: https://www.tachytelic.net/2018/08/office-365-how-to-change-primary-email-address

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s