Modifying ProxyAddresses for Office 365 Users Without Exchange Online

Migrating a Custom Domain from an Old Office 365 Tenant to a New One

As part of an Office 365 tenant rebuild, I had to move a custom domain from the old tenant to the new one. The old tenant was no longer needed, and the customer had to move to a Non-Profit tenant for compliance reasons. While the migration itself was straightforward, I encountered an issue with removing the custom domain from the old tenant. In this blog post, I will share my experience and the solutions I tried to resolve the issue.

Disabling AzureAD Sync and Changing UPNs

——————————————

The first step in the migration process was to disable the AzureAD sync and change the UPNs for all users. This was easy to do, and the PowerShell code in this article was quite helpful. However, even after completing these steps, I still could not remove the custom domain from the old tenant.

Removing the Custom Domain from ProxyAddresses

——————————————–

The issue was that the custom domain was still referenced in the ProxyAddresses attribute, which was synced by the AzureAD sync. Removing the domain from the users in the on-prem Active Directory was not a solution, as the users were already cloud-only because the sync was switched off. I knew that modifying the cloud-only users in the tenant was my best bet, but I was unsure how many users would be affected.

Using PowerShell to Remove Proxy Addresses

—————————————–

To my surprise, the Exchange Online Management PowerShell Module was quite helpful. The following line of code gave me an idea of how many users were affected:

“`powershell

Get-Mailbox -Filter {ProxyAddresses -contains “customdomain.com”} | Measure-Object -Property Count

“`

With my colleague Claudia, I quickly developed some dirty PowerShell code to remove all proxy addresses that included the custom domain. It took about 45 minutes to modify around 2000 users. After this, I was able to remove the domain and connect it to the new tenant.

Alternative Solution: Masking Out the Custom Domain

———————————————–

Another way to resolve this issue might be using the AzureAD sync itself, masking out the custom domain and waiting until the domain is removed from all proxy addresses. However, I did not test this method.

Conclusion

———-

In conclusion, migrating a custom domain from an old Office 365 tenant to a new one can be a straightforward process, but it’s important to be aware of potential issues that may arise. In my case, I encountered an issue with removing the custom domain from the old tenant, but was able to resolve it using PowerShell. If you find yourself in a similar situation, I hope this blog post will provide you with some helpful insights and solutions.