Hossain Labs

Home / Blog / Entra ID and Intune

Fixing Synced User Aliases Stuck on onmicrosoft.com in Hybrid Exchange

By Md Sajid Hossain1 December 20262 min read

Stuck with alias@domain.onmicrosoft.com as a synced user's primary address? Here's how to fix it.

In hybrid Exchange environments, this is a common issue: a user's primary email address is stuck on the onmicrosoft.com domain. It usually happens when the user is synced from on-premises Active Directory and their mail attributes weren't set up correctly in AD. Because the user is synced, AD is the source of authority, so you can't change the address directly in Exchange Online.

Try this first: In most cases, you can fix this without breaking sync. Make sure the custom domain (for example, contoso.com) is verified in your Microsoft 365 tenant. Then, in on-premises AD, set the user's mail attribute and add SMTP:john.doe@contoso.com (uppercase SMTP = primary) to proxyAddresses. Run a delta sync. Use the method below only if that doesn't work.

Step-by-Step Guide

  1. Isolate the User: In Active Directory, move the user's account from its synced Organizational Unit (OU) to a non-synced OU. This temporarily breaks the sync.
  2. Initiate Delta Sync: Run a delta sync with Microsoft Entra Connect (formerly Azure AD Connect):
    PowerShell
    Start-ADSyncSyncCycle -PolicyType Delta
  3. Verify Deletion: Confirm the user appears under Deleted users in the Microsoft 365 admin center or the Microsoft Entra admin center. Deleted users are kept for 30 days, so finish the next step well within that window.
  4. Restore and Re-license: Restore the user and, crucially, reassign the correct mailbox license.
  5. Cloud-Only Status: The user is now a cloud-only account, so you can change their addresses in Exchange Online.
  6. Set the Correct Primary Address (PowerShell): Add the address on your custom domain as the primary (uppercase SMTP:):
    PowerShell
    Set-Mailbox -Identity "john.doe@contoso.onmicrosoft.com" -EmailAddresses @{add="SMTP:john.doe@contoso.com"}
  7. Remove Old Alias (Optional): Remove the old alias if you no longer need it. Keep at least one onmicrosoft.com address if your environment relies on it for routing (for example, the hybrid mail.onmicrosoft.com address).
    PowerShell
    Set-Mailbox -Identity "john.doe@contoso.com" -EmailAddresses @{remove="smtp:john.doe@contoso.onmicrosoft.com"}
  8. Update On-Premises AD to Match: Before re-syncing, update the user's mail and proxyAddresses attributes in on-premises AD to match the new addresses. Once the user syncs again, AD becomes the source of authority again and will overwrite any changes made only in the cloud.
  9. Re-delete from Microsoft Entra ID: Delete the cloud user again so the on-premises account can match back to it.
  10. Return to Synced OU: Move the user's AD account back to its original synced OU.
  11. Execute Delta Sync: Run another delta sync from your Entra Connect server.
  12. Verify Update: The user reappears as a synced user with the updated primary address. Confirm with Get-Mailbox john.doe@contoso.com | Select PrimarySmtpAddress, EmailAddresses.

Important Considerations

  • Test First: Try this on a test account before using it on a production mailbox.
  • Downtime: The user may lose access to mail, Teams, and other services between the deletion and the restore. Schedule this outside working hours.
  • License Check: Always confirm the mailbox license is active and mail flow works afterwards.
  • Data Integrity: The mailbox is kept as long as the user is restored within the 30-day soft-delete window. Never permanently delete the user during this process.

This approach is particularly useful for company rebranding, mergers, or domain migrations, where controlling user aliases is crucial.

Md Sajid Hossain

Modern Workplace & Data Security Engineer in Dhaka. Microsoft 365, Purview, Entra ID and Exchange, from real tenants and support cases.

Work with me · LinkedIn