Remove leftover corporate software (MDM agent, privilege manager, EDR, VPN) from a Mac you own, and get your Administrator rights back. One script, run once from macOS Recovery.
Script:reclaim-mac-recovery.sh. Tested on Apple Silicon, macOS 27. Removes: Admin By Request, Trend Micro Apex One, Microsoft Intune agent, Palo Alto GlobalProtect, Company Portal. Edit the vendor lists inside for a different stack.
- You own the Mac โ personal device, already offboarded. Not a company-owned or still-managed machine.
- Not MDM-enrolled โ in normal macOS,
profiles status -type enrollmentmust showNo/No. IfYes, stop and go through IT.
- Your account has a Secure Token โ
sysadminctl -secureTokenStatus "$(whoami)"must sayENABLED. This is what lets you log in to Recovery. Without it, the only clean path is back up โ erase โ reinstall macOS.
Privilege managers (e.g. Admin By Request) demote your account to Standard. Once you uninstall their app, you have no admin and
sudo fails. The only way back in is Recovery, authenticating with your Secure Token account.- Put the script on the Mac, e.g. in
~/Downloads/.
- Enter Recovery: Shut Down โ press and hold the power button until "Loading startup options" โ Options โ Continue โ log in as your account.
- Mount the data volume (needed on Apple Silicon): Utilities โ Disk Utility โ select Macintosh HD - Data in the sidebar โ click Mount (enter your password if asked) โ quit Disk Utility. Skip if it is already mounted.
- Utilities โ Terminal, then run:
It auto-detects the data volume and your account, shows what it will remove, and asks forYES. It refuses to run outside Recovery.
1sh /Volumes/*/Users/*/Downloads/reclaim-mac-recovery.sh- Restart (Apple menu โ Restart).
- Verify in normal macOS:
1dseditgroup -o checkmember -m "$(whoami)" admin # yes
2profiles status -type enrollment # No / No
3sudo -v # asks password, no "not allowed"Regains admin (adds your GUID to the admin group) ยท removes vendor daemons, agents, apps, frameworks, helpers, support/log folders ยท strips vendor lines from
/etc/sudoers (validated) ยท resets the authorization database to Apple defaults ยท deletes installer receipts and per-user leftovers. Keeps /etc/sudoers.d/mole, Microsoft Office, and your own apps.- Orphaned system extensions in
systemextensionsctl listโ never enabled, not running (owning app is gone). Fully removing them needs SIP disabled; not worth it.
- Non-trusted vendor certs in Keychain Access โ login โ Certificates โ delete manually if you want.
Re-check the 3 prerequisites on each. The script detects the data volume, primary user (UID 501) and GUID automatically, so the same file works unchanged โ as long as the vendor stack matches. If a Mac fails the prerequisites, do a clean reinstall instead.
