Disabling Dynamics CRM Admin Mode via Powershell
I needed to Disable one of our CRM instances Admin Mode, I hit the Power Platform Admin Pages, it redirected me to Classic Dynamic 365 Administrator Center, clicked “Admin” for the Instance, it redirected me to Power Platform again and I started to get login error after a few browsers redirects between MS sites, it says “We couldn’t sign you in. Please try again.” Probably an authorisation token issue between MS sites.
I directly headed to Powershell, installed XRM Online Management API
Install-Module -Name Microsoft.Xrm.OnlineManagementAPI -RequiredVersion 184.108.40.206
And I used Disable-CrmAdminMode to do this, I’m writing these down to save my time if I will face it again, because finding values for parameters takes more time.
We will run this command
Disable-CrmAdminMode -InstanceId ’94…………………1′ -ApiUrl “https://admin.services.crm4.dynamics.com” -Credential $Cred
So we need your CRM Instance ID, and the ApiURL
The ApiURL here is not your Instance API Url actually this is the Service URL, each CRM Region has it own Service URL so you can find yours from https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/online-management-api/get-started-online-management-api#service-url
The following table lists the service URLs of Online Management API for worldwide Office 365 data centres.
|North America 2||https://admin.services.crm9.dynamics.com|
|Europe, Middle East and Africa (EMEA)||https://admin.services.crm4.dynamics.com|
|Asia Pacific (APAC)||https://admin.services.crm5.dynamics.com|
|United Kingdom (UK)||https://admin.services.crm11.dynamics.com|
Instance ID can be taken from CRM\Settings\Customisation\Developer Resources or you can run
Get-CrmInstances -ApiUrl “https://admin.services.crm4.dynamics.com”
to list your instances and find your Id for the respective CRM Instance.
Now we can run our command to disable admin mode for our CRM Instance easily.
$Username = “[email protected]”
$Password = “password”
$SecPassword = ConvertTo-SecureString $Password -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ($Username, $SecPassword)
Disable-CrmAdminMode -Id ‘Your Dynamics CRM Instance ID (GUID)’ -ApiUrl “Your Service URL from the table above” -Credential $Cred
This is all, now let’s check
Get-CrmInstance -Id “Your Dynamics CRM Instance ID (GUID)” -ApiUrl
Your Service URL from the table above -Credential $cred
Hope it helps