Erase and Install script

rjwick
New Contributor

I can't seem to get the script to work. I'm very new to Jamf and scripting. I want to erase and install my school lab.

I'm on High Sierra and I have the installer in my applications folder. This is the script I am using. I set up a policy to run it to lab scope. I dragged the startosinstall file into a Terminal window.

'/Applications/Install macOS High Sierra.app/Contents/Resources/startosinstall' ‑‑eraseinstall
--agreetolicense

I receive error message -

Executing Policy Erase and Install 3

Running script erase and install 3...

Script exit code: 127

Script result: /Library/Application Support/JAMF/tmp/erase and install 3: line 1: /Applications/Install macOS High Sierra.app/Contents/Resources/startosinstall: No such file or directory
/Library/Application Support/JAMF/tmp/erase and install 3: line 2: --agreetolicense: command not found

Error running script: return code was 127.

3 REPLIES 3

CSCC-JS
Contributor III

The entire command has to be in one line.

shaquir
Contributor III

Hi @rjwick There is no need to have quotes when you use backslashes.
I.e

 '/Applications/Install macOS High Sierra.app/Contents/Resources/startosinstall' ‑‑eraseinstall --agreetolicense ‑‑newvolumename 'Macintosh HD'

Is equivalent to:

/Applications/Install macOS High Sierra.app/Contents/Resources/startosinstall ‑‑eraseinstall --agreetolicense ‑‑newvolumename 'Macintosh HD'

sdagley
Esteemed Contributor II

@rjwick In addition to the proper quoting that @shaquir points out, be aware that startosinstall requires a logged in user to run if you're planning on pushing the command to your lab using a Jamf Pro Policy triggered by something other than Self Service

I'm also going to put in a plug here for the macOSUpgrade script written by @Rosko, a Jamf engineer, as it's a much more comprehensive update script than just calling startosinstall. If nothing else it'll give you some ideas on scripting.