Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Intune Group Policy auto-enrolment error 80180002b: "Auto MDM Enroll: Failed" on a Windows 10 device

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

When a Windows 10 device that is meant to enrol in Intune through Group Policy never appears in the Intune console, and the device's own log shows event 76 with "Auto MDM Enroll: Failed (Unknown Win32 Error code: 0x80180002b)", Microsoft's page says the device was previously joined to a different tenant and did not unjoin from it correctly. Old tenant details are still on the device, and the page says the values used to get a Primary Refresh Token are incorrect.

The fix on the page is to remove the device from both Microsoft Entra ID and the on-premises domain, rejoin it, and sign in again. That is a heavy change for one device, so prove the cause first.

What the error means

Microsoft's page is titled "80180002b error during Windows 10 Group Policy-based auto-enrollment to Intune". It describes two symptoms when you try to enrol a Windows 10 device automatically by Group Policy.

First, Event Viewer logs this event under Applications and Services Logs, Microsoft, Windows, DeviceManagement-Enterprise-Diagnostics-Provider, Admin:

  • Log Name: Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin
  • Source: DeviceManagement-Enterprise-Diagnostics-Provider
  • Event ID: 76
  • Level: Error
  • Description: Auto MDM Enroll: Failed (Unknown Win32 Error code: 0x80180002b)

Second, when you run dsregcmd /status on the device, AzureAdPrt is NO, "This indicates that the user isn't authenticated to Microsoft Entra ID when signing in to the device." The values of TenantId and AuthCodeUrl are also incorrect.

Microsoft's device-diagnostics page defines the field: AzureAdPrt is set to YES if a Primary Refresh Token (PRT) is present on the device for the signed-in user.

Likely causes

The page gives one cause. The device "was previously joined to a different tenant and didn't unjoin from the tenant correctly." The registry key HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\CloudDomainJoin\TenantInfo\<TenantId> still holds the old tenant's information. The AuthCodeUrl and AccessTokenUrl values in those keys are used to get a PRT, and because they are incorrect, AzureAdPrt is NO.

Other things stop automatic enrolment, but they are not this error. Microsoft's Group Policy enrolment page lists requirements: a supported Windows version, an MDM service configured, on-premises Active Directory integrated with Microsoft Entra ID through Microsoft Entra Connect, service connection point configuration, and a device not already enrolled in Intune with the classic agents, which "fail enrollment with error 0x80180026". If the device's TenantId is already your tenant, this error probably has another cause.

Prove the cause before changing anything

All of these only read. Run them on the affected device.

  1. Confirm the event. In Event Viewer, open the log path above and find event 76 with 0x80180002b.
  2. Run dsregcmd /status and note AzureAdPrt, TenantId, AuthCodeUrl, DeviceId, AzureAdJoined and DomainJoined. Microsoft's device-diagnostics page says to run it as a domain user account, and that it shows the state of the device in Microsoft Entra ID.
  3. Compare TenantId with your own tenant's ID. If it is a different tenant's, that matches the page's cause. If it is yours and AzureAdPrt is YES, this error probably has a different cause.
  4. Check the registry key above for a <TenantId> subkey that is not your tenant. The page says the old tenant's values remain there.

Example (illustrative): a laptop at contoso.com.au was used at a previous employer's tenant before purchase and reset without being removed from it. dsregcmd /status shows AzureAdPrt : NO, and TenantId is a GUID that is not Contoso's. The CloudDomainJoin key contains that GUID. The old tenant is still recorded on the device.

Fix

The page's solution has eight steps. Two of them delete the device object from where it is registered, so confirm the device first: if the saved output shows a DeviceId (Microsoft's device-diagnostics page shows that section only for a joined or hybrid joined device), it is the identifier of the object to delete in Microsoft Entra ID, and the computer name is the object to delete from the domain.

Save the dsregcmd /status output to a file before you change anything, because you need DeviceId and the tenant details to pick the right object in Microsoft Entra ID and the domain:

dsregcmd /status > C:\Temp\dsregcmd-before.txt

Disruptive step: the next steps remove one device from the domain and from Microsoft Entra ID and then join it again, and step 4 starts a directory sync cycle for the whole Microsoft Entra tenant, not only for this device. Until it is rejoined, the device is not a member of the domain, so what the domain and Intune apply to it is not applied. Do it for the one device the proof identified, with the user's agreement and at a time they can be without the device, and not for a batch.

  1. On the affected device, open an elevated Command Prompt window and run dsregcmd /leave.
  2. Delete the device in Microsoft Entra ID.
  3. Unjoin the device from your on-premises Active Directory domain, then delete the device object from the domain controller.
  4. Rejoin the device to the on-premises Active Directory domain, then start a sync cycle from PowerShell: Start-ADSyncSyncCycle -PolicyType Delta. Microsoft's sync scheduler page confirms that this command runs a manual delta cycle.
  5. Run dsregcmd /status on the device and verify that both AzureAdJoined and DomainJoined are YES.
  6. Sign out, then sign in again to get a PRT.
  7. Run dsregcmd /status again and verify that AzureAdPrt is YES and the tenant information is correct.
  8. Run gpupdate /force to force an update of all Group Policy settings, then verify that the device is enrolled in Intune.

To undo it: removing the device object from Microsoft Entra ID and from the domain cannot be reversed from the saved output; the saved file only records what the device looked like. Rejoining creates a new object. If the unjoin fails partway, the device can be rejoined to the domain with the same name using your normal join process, which the page does not describe.

If the device must keep its domain object for another reason, such as a recorded name or an assigned role, note it before step 3. The page does not say what else the object carries.

Confirm the fix

  • dsregcmd /status shows AzureAdJoined : YES, DomainJoined : YES and AzureAdPrt : YES, with a TenantId that is your tenant's.
  • Event 76 no longer reports 0x80180002b for new enrolment attempts.
  • The device appears enrolled in Intune. Microsoft's enrolment page says to check from Start, Settings, Accounts, Access work or school, select the domain account, then Info, which shows the MDM enrolment information.

What to watch afterwards

  • Other devices reused from another tenant. The page's cause is a device that did not unjoin correctly, so check the registry key and TenantId on any second-hand or transferred device before enrolling it.
  • A task created by the policy. Microsoft's enrolment page says that when a Group Policy refresh occurs a task is created and scheduled to run every five minutes for one day, named "Schedule created by enrollment client for automatically enrolling in MDM from Microsoft Entra ID". Seeing it run is a sign enrolment is being attempted.
  • The Group Policy itself. The page describes "Enable automatic MDM enrollment using default Microsoft Entra credentials", under Computer Configuration, Administrative Templates, Windows Components, MDM.

If the policy itself is missing or misapplied

Microsoft's enrolment page describes how the policy is meant to be deployed, which helps when only some devices fail. You create a Group Policy Object that enables Computer Configuration, Administrative Templates, Windows Components, MDM, "Enable automatic MDM enrollment using default Microsoft Entra credentials", create a security group for the PCs, link the GPO and filter using the security group. If you do not see the policy in the editor, the page says to get the latest ADMX for your Windows version, install the package on a domain controller, copy the PolicyDefinitions folder to the SYSVOL PolicyDefinitions location or your central policy store, and wait for the SYSVOL DFSR replication to complete.

The page also says that in Windows 10, version 1903 and later the policy can use a Device Credential option, supported only for Intune enrolment in co-management or Azure Virtual Desktop multi-session host pools, and that the default behaviour for older releases is User Credential. A device that fails with 0x80180002b has a tenant mismatch; as an inference, a device where the policy never arrives has a Group Policy problem, which is a separate fault.

Risks and limits

These steps have not been run or lab-tested.

Microsoft's page covers Windows 10 and gives one cause. It does not say how to delete a device in Microsoft Entra ID or from the domain, what happens to BitLocker keys, user profiles or applications, or how to reach the registry key's contents safely. It also does not say which server runs the sync command; Microsoft's scheduler page describes the command only. Do not edit the CloudDomainJoin registry key by hand on the strength of Microsoft's page, which does not give that step.

Sources