Skip to content

Instantly share code, notes, and snippets.

@mardahl
Last active August 5, 2022 17:07
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mardahl/db57e7fca3926091a8c2d60461f08ad2 to your computer and use it in GitHub Desktop.
Save mardahl/db57e7fca3926091a8c2d60461f08ad2 to your computer and use it in GitHub Desktop.
Intune Enrollment problem solver script thingy
# Clean out MDM registration info from machine, in attempt to fix Intune enrollment problems with Windows 10
# after a user reboots, the enrollment process should kick off again.
# This special edition, also disables workplace join, as an attempt to mitigate issues with devices previously AAD Registered.
# This script has fixed Error codes 0x80180023 and 0x8018002b at some of my customers sites, even without reboot in some cases.
# By Michael Mardahl @ Apento.com - @michael_mardahl
# Should be run as system user
#Disable workplace join if that is happening beyond your control.
#Get-ScheduledTask -TaskName "Automatic-Device-Join" | Disable-ScheduledTask
#Get-ScheduledTask -TaskName "Recovery-Check" | Disable-ScheduledTask
#you can try either one of the two following actions afterwards, or both (test test test)....
#Remove AAD registration from Machine.
& $env:WINDIR\system32\dsregcmd.exe /leave
#Re-run deviceEnrollment
& $env:WINDIR\system32\deviceenroller.exe /c /AutoEnrollMDM
@mardahl
Copy link
Author

mardahl commented Mar 11, 2019

The issues can arise from computers that have mistakenly been workplace joined (Azure AD Registered) etc.

Try and mix the commands around, I found that it's a trial and error thing, and waiting is also key, sometimes you need to do the /leave command, and then wait like 8 hours, before restart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment