Last Updated on August 31, 2022 by rudyooms
This blog will show you how you could make sure, your existing Azure Ad Joined devices (Devices that are not yet enrolled into MDM / Intune) are going to be automatically enrolled into Intune.
I will divide this blog into multiple parts
1. The Issue
A lot of customers will start their cloud journey by making use of Azure Ad as their Identity Provider. Most of the time, Intune wasn’t yet part of that journey. But what if you want to make sure your devices are being managed and the devices are already enrolled into azure but not into Intune?
Today I spend some time enrolling existing Azure Ad joined devices into Intune. These devices were Azure Ad joined butt without MDM/Intune enabled or configured.
This company started off with only Microsoft 365 Business standard licenses. We all know that this license type is missing the possibility to enroll the devices into Intune.
2. Solving it
When you want to enroll your existing Azure Ad joined device into Intune, there are multiple options available to make sure the device will be enrolled into MDM/Intune. Of course, when enrolling an existing Azure Ad Joined device into Intune there is 1 major requirement. You will need to have the right privileges (local administrator) to perform that operation! Otherwise, you will end up with some nice errors
If the permissions aren’t going to be an issue we still need to check out some other settings. To make sure users could enroll their device we need to configure the MDM scope in Intune. As shown below we made sure only users with a proper license (Business Premium) could enroll their device into MDM.
Please note: Before enrolling the device, also make sure there are no enrollment restrictions(Block Personal Devices) configured!
If we have the prerequisites configured we could start enrolling the device into MDM/Intune. To do so we have multiple options at our disposal.
Option 1: Group Policy:
You can open the group policy object editor and browse to
Computer Configuration > Administrative Templates > Windows Components > MDM.
And configure this setting like the picture below:
*Enable: “Automatic MDM enrollment using default Azure credentials“
*Credential Type to use: User credentials
Make sure that after you configured this settings you perform a gpupdate on the device
Option 2. Registry:
Instead of changing a GPO setting, we could also change the corresponding registry setting ourselves. So just import this reg file with the required enrollment information in it.
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\MDM] "AutoEnrollMDM"=dword:00000001 "UseAADCredentialType"=dword:00000001
It does the same as the GPO as a GPO is nothing more than a bunch of registry changes… 🙂 .. so again please make sure that you perform a gpupdate on the device after configuring this registry key
Option 3. PowerShell
And of course, you could also just deploy this PowerShell script to your devices to make sure the device will start enrolling into MDM/Intune/Endpoint Manager
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\MDM" New-Item -Path $registryPath $Name = "AutoEnrollMDM" $Name2 = "UseAADCredentialType" $value = "1" new-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null new-ItemProperty -Path $registryPath -Name $name2 -Value $value -PropertyType DWORD -Force | Out-Null gpupdate /force
When you applied one of these options I described above, you will notice a new Task will be created in the task scheduler. A new nice Category: EnterpriseMgmt will be created with a task named: “schedule created by enrollment client for automatically enrolling in MDM from AAD” in it. This task runs every 5 minutes for a duration of 1 day and will try to run C:\Windows\system32\deviceenroller.exe with these arguments /c /AutoEnrollMDM
Give it some time because sometimes it could really take long before the device will be enrolled into Intune successfully. In the meantime, you could notice the error Auto MDM Enroll: Failed 0x8018002b (event 76) popping up in the DeviceManagement-Enterprise-Diagnostic event log.
Sometimes it could take over more than a few hours, also putting the device to sleep or logging out the user will keep you waiting. After some time of waiting you will notice event 75 with the message that Auto MDM Enroll: Succeeded
4. Speeding up the Enrollment
When you don’t want to wait until you are an old person, and you want to speed it up.
Please enforce enrollment by running the DeviceEnroller command in the System context (PSEXEC). As shown below, I am also making sure the MdmENrollmentUrl is configured before we start the enrollment!
$key = 'SYSTEM\CurrentControlSet\Control\CloudDomainJoin\TenantInfo\*' $keyinfo = Get-Item "HKLM:\$key" $url = $keyinfo.name $url = $url.Split("\")[-1] $path = "HKLM:\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\TenantInfo\$url" New-ItemProperty -LiteralPath $path -Name 'MdmEnrollmentUrl' -Value 'https://enrollment.manage.microsoft.com/enrollmentserver/discovery.svc' -PropertyType String -Force -ea SilentlyContinue; New-ItemProperty -LiteralPath $path -Name 'MdmTermsOfUseUrl' -Value 'https://portal.manage.microsoft.com/TermsofUse.aspx' -PropertyType String -Force -ea SilentlyContinue; New-ItemProperty -LiteralPath $path -Name 'MdmComplianceUrl' -Value 'https://portal.manage.microsoft.com/?portalAction=Compliance' -PropertyType String -Force -ea SilentlyContinue; C:\Windows\system32\deviceenroller.exe /c /AutoEnrollMDM
If you don’t execute this command in the system context you will notice a nice error mentioning: “Auto MDM ENroll: Device Credential (0x0), Failed (Access is denied). So please use PSEXEC to speed things up!
For the people who don’t believe that this process will only take a few seconds, here you go
5. Troubleshooting the Enrollment
I removed this part from this blog because it was becoming too large and while becoming too large it was overshadowing the main part of the blog. Please visit this blog if you are dealing with Intune Enrollment Errors
When your devices are already enrolled in Azure Ad, it doesn’t mean you will need to reinstall the devices to make sure those devices are enrolled into Intune/MDM. Sometimes enrolling a device into Intune sounds easier than it is… hopefully the troubleshooting part showed you how to deal with those kinds of situations!
Please Note: Wiping the device and enrolling it with Autopilot is the path you will need to take… but sometimes that path isn’t always available!