Skip to content

6. Use in Jamf Pro

Graham Pugh edited this page Aug 31, 2023 · 11 revisions

There are two ways you can use the script in Jamf Pro.

Option 1: Installer package (recommended)

The installer package contains the latest copies of erase-install.sh, mist and swiftDialog. erase-install.sh is installed into the /Library/Management/erase-install folder.

Attach this package to a policy, and use the Execute Command field to run the script with the desired parameters, for example:

/Library/Management/erase-install/erase-install.sh --os 12 --update --reinstall --confirm

Alternatively, you can add a launcher script to the policy that runs the above command. The advantage of a launcher script is that if erase-install fails for some reason, this will get reported as a failure to the Policy Logs, whereas the Execute Command always returns a success. For an example of such a script, see erase-install-launch-script-example.sh in this repo.

Option 2: Upload erase-install.sh into Jamf Pro and use policy script parameters

If you upload the script directly into Jamf Pro, and are intending to attach it to a policy, then you can use script parameters to provide the arguments.

In the script parameters of the Policy (not the Parameter Labels of the script itself!!), add the desired options, including the -- double-dashes, just as if you are supplying them in the command line. Any parameters which provide a value must use an = so that they are interpreted as a single parameter. It does not matter which order the parameters are added.

For example, to create a policy named Erase and Reinstall macOS which is scoped to models of Mac that will reinstall the same macOS Version as is currently installed, set parameters as follows:

  • Parameter 4: --erase
  • Parameter 5: --sameos

If you want to download a particular version of macOS, create a policy scoped to the devices that require the specific version, and set parameters as follows (make sure to use an equals sign for parameters that require a value):

  • Parameter 4: --erase
  • Parameter 5: --version=12.6.2

If you want to upgrade to the latest macOS, use:

  • Parameter 4: --reinstall

If you want to upgrade to the latest macOS and ensure that any cached version is replaced when it gets out of date:

  • Parameter 4: --reinstall
  • Parameter 5: --update

If you want to upgrade Macs running Big Sur (11) to the latest version of Monterey (12), use:

  • Parameter 4: --reinstall
  • Parameter 5: --os=12

If you just want to cache the latest installer app on the client, then I recommend this parameter:

  • Parameter 4: --update

Just to reiterate, any parameter can be supplied in any order in the policy's Script Parameters section, and only one parameter can be supplied into each Parameter field. There is of course a limit of 7 parameters using this method. If you need more parameters, I recommend that you deploy the package as described in Option 1.

Option 3: Run the script directly from GitHub

You can use a Run Command or a launcher script that uses curl to download the script directly from GitHub without having to upload it to Jamf. Arguments/parameters can be supplied in the command.

curl -s https://raw.githubusercontent.com/grahampugh/erase-install/release/erase-install.sh | sudo zsh /dev/stdin <arguments>

A note about Policy Logs

Please note that when using this script in a Jamf policy with the --erase or --reinstall options, the policy will not be logged as completed, because the computer restarts before the script can complete. Therefore, it is important that you do not have this policy set to run automatically on a "Once Per Computer" basis. I recommend that you use it in Self Service, and for use with --reinstall (for upgrading) scope based on whether the OS you want to be installed is already on the client. For this to work effectively, you will want to create a policy that Updates Inventory on startup.

If you use a separate launcher script you can at least get a recon sent if the policy fails. See our example launcher script here.