Category filter

Script to wipe and reinstall macOS

Apple regularly releases OS upgrades to repair bugs and improve the security of the OS. So naturally, organizations prefer that their devices run the most recent OS version. The sheer number of devices, however, makes it difficult for the IT department of any firm to deploy OS updates. So here is a script that will remotely wipe and reinstall macOS to the latest version. You can deploy it using Hexnode’s Execute Custom Script action.

Disclaimer:


The Sample Scripts provided below are adapted from third-party Open-Source sites.

Wipe and reinstall macOS

Notes:

  • Running this script will completely erase your device. So back up your device not to lose important data.
  • The fully automated script supports Catalina (10.15) to Monterey (12.0).
  • For Apple Silicon Macs or devices with OS version Big Sur, simply pass the admin password as an argument while running the script from the portal.
  • Ensure your device is plugged in and has sufficient space to download updates before initiating OS update.

The script functions in the following manner. First, the script fetches device info such as the current OS version and processor. If the OS version is less than 10.15, a prompt is displayed “This script supports only 10.15 or higher”.

Then, the script fetches the installer of the latest version of the OS supported by the device. This means that if the device is on Big Sur Version 11.2.1 then the script installs the latest version of Big Sur (11.5).

The script may crash while fetching or preparing the installer and can return an error. In that case, run the following command:

This ensures the installer is already available in your Applications folder when you run the script.
Ensure installer is present on your device before initiating OS wipe and reinstall

The script completely wipes the device and reinstalls a brand-new OS version on your macOS device.

Notes:

  • Scripts may be in ‘Initiated’ status for an extended period of time depending on network connectivity as a large number of updates are downloaded.
  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository