• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Tachytelic.net

  • Sco Openserver
    • Sco Unix Support
    • SCO Openserver Installation ISOs
    • SCO Openserver Binaries
    • Add a Hard Drive to an Openserver 5 Virtual Machine
    • Install SCO Vision SQL-Retriever ODBC Driver on Windows 10
    • License Expired on Virtual SCO Openserver Installation
    • How to reset the root password on SCO Openserver 5
  • Scripting
    • PowerShell
      • Add leading zeros
      • Check if a File Exists
      • Grep with Powershell
      • Create Environment Variables
      • Test for open Ports
      • Append to a Text File
    • VBScript
      • Check if a File Exists
      • lpad and rpad functions
      • Windows Update E-Mail Notification
  • Office 365
    • Connect to Office 365 with PowerShell
    • Add or remove an email alias using Powershell
    • Change Primary email address of Active Directory user
    • How to hide an AD user from the Global Address List
    • How to hide mail contacts from the Global Address List
    • Change the primary email address for an account with PowerShell
    • Change Primary email address of an AD User
    • Grant a single user access to access to all calendars
    • Forward email to an external address using Powershell
    • Convert shared mailbox to user mailbox with Powershell
  • Get in Touch
  • About Me
    • Privacy Policy

Office 365: Change Primary email address of Active Directory user

August 20, 2018 by Paulie 9 Comments

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:

Set-ADUser paulie -Add @{ProxyAddresses="SMTP:[email protected]"}

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:

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:

Set-ADUser paulie -Remove @{ProxyAddresses="smtp:[email protected]"}

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 page in order to get the attributes enabled for your users.

If you have any questions, feel free to ask in the comments.

Related

Filed Under: How To, Office 365 Tagged With: E-Mail, Exchange, Office 365, Powershell

Reader Interactions

Comments

  1. Mezza says

    August 20, 2018 at 3:02 pm

    Very useful! Thank you!

  2. sh10 says

    December 25, 2018 at 9:27 am

    THX

  3. Nelson Matias says

    January 23, 2019 at 5:16 pm

    Thanks!!!!

  4. Keith Wallace says

    February 21, 2019 at 3:50 pm

    Thank you very much! If we wanted to do this for all users how would the script read?

  5. Paulie says

    February 21, 2019 at 4:09 pm

    Can you explain a little more about what you would like to achieve?

  6. Mike Gusway says

    February 25, 2019 at 4:13 pm

    We are running Azure AD Connect to sync our on-prem AD with O365. All mailboxes are remote. When we use Enable-RemoteMailbox our email address policy creates some custom aliases but for this particular user we don’t want it to apply. How can we exclude a specific user from the email address policy using PowerShell? In O365 I don’t see a way to disable this, and on our on-prem Exchange (only used for management), the get-mailbox and set-mailbox commands for users don’t work since there are no local mailboxes. I’m looking for the equivalent of set-mailbox -Identity username -EmailAddressPolicyEnabled $False
    Thanks!

  7. Earl says

    December 12, 2019 at 2:21 am

    thanks this really helped

Trackbacks

  1. Setting the primary email address for Office 365 users with PowerShell says:
    August 24, 2018 at 11:32 am

    […] http://tachytelic.net/2018/08/office-365-how-to-change-primary-email-address/ […]

  2. Office 365: How to change primary email address when using Dirsync,AADSync or Azure Active Directory Connect | gioshio says:
    November 20, 2018 at 10:13 am

    […] sourse: http://tachytelic.net/2018/08/office-365-how-to-change-primary-email-address […]

Leave a Reply Cancel reply

Primary Sidebar

Link to my LinkedIn Profile
Go to mobile version