Skip to content

rnddave/remove-mdm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Saving WEEE Waste MacBooks (and a Mac Mini) from Landfill

I run a YouTube channel where I try to rescue aging MacBooks from landfill. Most of the time, this is a smooth process. I either receive or purchase an old Apple computer that still looks great but has aged out of Apple's support cycle. I don’t want a house full of old Macs (not old enough to be vintage, but old enough to be useless in Apple’s eyes), so I usually have an idea of who will receive the device when I’m finished.

Depending on the recipient, I either install a Linux distribution or, if the hardware is a bit newer and/or the intended user is less likely to thrive in the Linux world, I use the fantastic Open Core Legacy Patcher (OCLP) to install a newer MacOS version. OCLP tricks older hardware into running MacOS versions that Apple no longer officially supports. This tool has matured well and makes it relatively easy to install newer MacOS versions on older Macs.

Find out more about OCLP here.

Mobile Device Manager

Sometimes, I come across nice-looking Macs (so far, a couple of portables and even a Mac Mini) that have been enrolled in Mobile Device Management (MDM). This allows companies to control what users install, enforce security policies (e.g., password complexity, disk encryption), and manage remote device access. MDM can also be used to remotely lock or wipe a device, which is particularly useful for lost or stolen company assets.

It's important to distinguish MDM from Activation Lock or a T2 Locked device. Click here to learn more about bypassing T2 Locked devices.

Reasons to Remove an MDM

Let me be absolutely clear, this is not a guide for bypassing security on stolen MacBooks. If that’s what you’re looking for, you’re in the wrong place.

For legitimate users, however, there are valid reasons to bypass MDM, such as:

  1. Preventing WEEE Waste.
  2. Regaining control over a personally owned or retired work device.
  3. Troubleshooting issues (even IT staff sometimes need to bypass MDM without permanently removing enrollment).

How to Remove an MDM

Prerequisites ⚠️

  • Device language must be set to English. It can be changed afterward. (at least for my script to work)
  • A fresh MacOS installation is recommended but not required.

Steps:

  1. Boot into Recovery Mode.
  2. Use Disk Utility to erase the current disk.
  3. Rename your new volume (optional, but "Macintosh HD" is recommended).
  4. Reinstall MacOS (from Recovery Mode or an external USB installer).

Once installation is complete, the device will restart and present the setup wizard. One of the first steps is the network setup, so join the network and when you see the MDM Enrollment message, then DO NOT proceed past this step! Instead:

  1. Turn off the device.

  2. Boot back into Recovery Mode:

    • Apple Silicon Macs: Hold the power button.
    • Intel Macs: Hold CMD + R during boot.
  3. Connect to Wi-Fi.

  4. Open Safari and navigate to the script in my GitHub repo.

  5. Copy the following command:

    curl https://github.com/rnddave/remove-mdm/blob/main/mdm-cleaner.sh -o mdm-cleaner.sh && chmod +x ./mdm-cleaner.sh && ./mdm-cleaner.sh
  6. Open Terminal (Utilities > Terminal).

  7. Paste the command (CMD + V) and press Enter.

  8. Select 1 to run the MDM bypass script.

  9. Press Enter to accept the default username (Apple).

  10. Press Enter to accept the default password (12345).

  11. Wait for the script to finish and reboot your Mac.

After Rebooting

  1. Log in with Username: Apple | Password: 12345.
  2. Skip setup steps (Apple ID, Siri, Touch ID, Location Services).
  3. Go to System Settings > Users and Groups and create your proper user account (probably a good idea to set yourself as an Admin).
  4. Log out of the temporary Apple account and log into your new account.
  5. If your new account is an admin, delete the temporary Apple account.

I Don't Want to Wipe My MacOS Installation—What Can I Do?

This is not guaranteed to be trouble-free and depends on the age of your device and how your system administrator has configured it. If Secure Boot is enabled (which is common for Macs after 2017), you may need an admin password to access Recovery Mode.

However, if you can access Recovery Mode without an admin password, you can try the following:

  1. Open Terminal (Utilities > Terminal).

  2. Type cd /Volumes/ and then ls to list available volumes.

  3. Identify the correct system volume (e.g., "Macintosh HD").

  4. Run (where $system_volume is the name of your volume as per step 3):

    rm -rf /Volumes/"$system_volume"/var/db/ConfigurationProfiles/Settings/.cloudConfigHasActivationRecord
    rm -rf /Volumes/"$system_volume"/var/db/ConfigurationProfiles/Settings/.cloudConfigRecordFound
    touch /Volumes/"$system_volume"/var/db/ConfigurationProfiles/Settings/.cloudConfigProfileInstalled
    touch /Volumes/"$system_volume"/var/db/ConfigurationProfiles/Settings/.cloudConfigRecordNotFound
  5. Block MDM servers:

    echo "0.0.0.0 deviceenrollment.apple.com" >>/Volumes/"$system_volume"/etc/hosts
    echo "0.0.0.0 mdmenrollment.apple.com" >>/Volumes/"$system_volume"/etc/hosts
    echo "0.0.0.0 iprofiles.apple.com" >>/Volumes/"$system_volume"/etc/hosts

Final Warning

Tampering with MDM settings—especially on a work-issued device—could have serious consequences, including termination of employment. This guide is intended only for IT professionals troubleshooting company devices and System Recyclers.

Sometimes fixing things means breaking them a little first…