change the User ID that is being used to login to Office 365

I need to change the User ID that is being used to login to Office 365.  We have an on site Exchange 2010 server and have migrated to Office 365.  Our current domain and email address is and Microsoft created us a domain called  My users really have two email addresses, and  This is fine and we are using AD synchronization which is working fine.  

However, it makes my users log into their accounts with the account when accessing email or 365 in the cloud.  But at work in our domain, they are accustomed to using  Is their a way I can make it allow them to login with the other account id instead of the one Microsoft created?

Lanee KirbyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vasil Michev (MVP)Commented:
Do you "own" the domain and have you verified it in O365? If you need help with the process, read here:

Once that is done, you can use the domain to assign UPNs/EmailAddresses to the users, so they can match across on-premises and O365. To change the UPN, you can use the Set-MsolUserPrincipalName cmdlet:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Todd NelsonSystems EngineerCommented:
Do you have the domain added to O365, and if not, can you add it?
Lanee KirbyAuthor Commented:
We do own the domain and I have added it O365 and it is listed as the (default) domain.  However, we have always (about a year now) had to login to O365 with our login account name.  I read articles about what your suggestion is supposed to do.  Help me understand please.  In my User profile account in AD on site, their User profile name is User @ (long, long ago, when my domain was created, the person put the name local in it).  In their AD profile it lists their email address as

In O365, it lists both addresses, and  It lists as the primary but it lists the User profile as User @

Question is The powershell command is supposed to change the User ID in O365, not locally in my AD, since it is already correct?  I cannot manually change it in O365 even though their is a drop down box.

Thanks for any clarification.

Vasil Michev (MVP)Commented:
Email addresses dont matter here, only the UserPrincipalName. You can change it in O365 directly, via the PowerShell cmdlet I linked above.

The on-premises and O365 UPNs dont need to match, although it's a good practice to keep them in sync.
Lanee KirbyAuthor Commented:
Thank you for your assistance.  The command Set-MsolUserPrincipalName did not make the necessary changes that I needed.  It actually failed saying it did not know what that parameter meant.  
However, upon searching some more, I found this command that did exactly what I needed.
Set-Mailbox "" -MicrosoftOnlineServicesID ""
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.