-
Notifications
You must be signed in to change notification settings - Fork 162
CUT-5058: Update MDM Removal Script #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
jworkmanjc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retested, working for me
kmaranionjc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested good on my end
Issues
What does this solve?
The purpose of this is to create parity between the MDM Removal process in ADMU and in the Support repo. Currently, there is 2 different logic patterns between the two repos and we'd like to consolidate these so it is easier to maintain in ADMU.
The script has been edited to have clear function definitions that will be used in the ADMU Actions workflows to compare the definitions declared in the Support script versus the definitions declared in ADMU. If these definitions are different, the ADMU workflow will fail and prompt to be updated.
We also needed to add a check for the
MmpcEnrollmentFlagin the registry. Basically if that key's value is something other than0, the device could still think that it is MDM enrolled. The script will now check the value and if it is not0, it will set it0.Is there anything particularly tricky?
The script has been updated to have function definitions for all steps. The actual MDM removal process has been refactored to be a new function called
Remove-WindowsMDMProviderThe script will still be executed the same way as it was before; the main difference is the
Remove-WindowsMDMProviderfunction is called with the-forcePruneoptional param (this won't be used in ADMU however it is needed for the Support script).How should this be tested?
./remove_windowsMDM.ps1Screenshots
Screenshot of jcMDMCleanup.log file
Screenshot of terminal after running remove_windowsMDM.ps1
Note
Medium Risk
Touches a destructive Windows cleanup script that deletes registry keys, scheduled tasks, and certificates, and changes its execution flow (new
ForcePrunebehavior and registry flag reset). Mistakes could remove the wrong artifacts or fail to fully unenroll devices.Overview
Refactors the Windows MDM cleanup PowerShell script into clearer, reusable functions, centered around a new
Remove-WindowsMDMProviderentry point with optional-EnrollmentGUIDtargeted cleanup and-ForcePruneorphaned-GUID sweep.Adds a new pre-cleanup step to reset
HKLM:\SOFTWARE\Microsoft\Enrollments\MmpcEnrollmentFlagto0when present, and updates the script’s main execution to callRemove-WindowsMDMProvider -ForcePrunewith structured error handling and final verification viaGet-WindowsMDMProvider.Written by Cursor Bugbot for commit 0502a9d. This will update automatically on new commits. Configure here.