Microsoft PowerShell script to unfederate a Microsoft 365 domain from RM Unify
Published Date : 02 Jan 2020
Last Updated : 01 Jun 2023
Content Ref: DWN7126758
Operating System
(none)
Part No
(none)
Summary
Provides PowerShell script which will unfederate the Microsoft 365 domain and clear the OnPremisesImmutableId property of all users to facilitate direct sign in to Microsoft 365.
Description
Provides a Microsoft® PowerShell® script which will unfederate the Microsoft 365™ domain and clear the OnPremisesImmutableId property of all the users in the domain to facilitate direct sign in to Microsoft 365.
You are using this article in conjunction with the article TEC3229605, see Other Useful Articles section below.
In the dialog box that appears, select 'Save as'. When the Save As window is displayed and prompts for a location to save the download to, browse to the folder where you want to save it and click Save.
When the download has finished, click Close.
Extract the file to a location of your choice.
In Google Chrome:
Right-click the disk icon and select 'Save link as'.
When the Save As window is displayed and prompts for a location to save the download to, browse to the folder where you want to save it and click Save.
When the download has finished, click Close.
Extract the file to a location of your choice.
Download
Filename
File Size
Download
unfederate_m365domain_from_rmunify.ps1
5 kb
Installation Instructions
Please check that you have working credentials for a Microsoft 365 global administrator account, with a username on your initial 'onmicrosoft.com' domain, e.g. JSmith@SchoolA.onmicrosoft.com. Important: You may inadvertently lock yourself out of your tenancy if you unfederate using a global administrator on your federated domain.
Open a new PowerShell window and change the folder location to where you extracted the script file.
Run the script file.
When prompted, enter the Microsoft 365 domain name you wish to unfederate.
When prompted, enter your Microsoft 365 global administrator credentials. If the details entered are correct, the script will unfederate your Microsoft 365 domain, and clear the Immutable IDs of all users in the domain. For 1000 users, this will take approximately 20 minutes.
Wait until the script runs to completion.
Once completed, you will see the message: ******************************************************************************************************************* Unfederation completed successfully. No users on <domain> have an OnPremisesImmutableId.
Please wait a further 60 minutes to allow Microsoft to fully process the domain conversion. Users will then be able to sign in to Microsoft 365 and Office after you have assigned a password to their Microsoft 365 user account.
Please refer to Microsoft online support for further help on resetting user passwords and how users can sign in. *******************************************************************************************************************
If your domain is already unfederated, you will get the message: "Domain <domain> is not federated. Do you still want to proceed with clearing user OnPremisesImmutableId? Please enter y/n."
Possible Issues
Script reports a failure to remove OnPremisesImmutableId
The script may fail to remove the OnPremisesImmutableId of a user, reporting that the affected account is a local account and not a cloud account.
This can occur when the domain is not fully federated to RM Unify at the time you ran the script and the affected M365 account was originally created in M365 by synchronisation with AD, e.g. previous use of Azure AD Connect. Microsoft may prevent removal of the OnPremisesImmutableId on M365 accounts it believes are still linked to your AD.
To successfully remove the OnPremisesImmutableId, you must convert the affected M365 account to a cloud account and re-run the script. There are multiple ways to do this depending on your own setup. Please refer to your network support provider or Microsoft for further advice.
If this article has not helped provide a solution then it is also possible to
log a call...