softwareupdate fetch latest installing old OS

james_spencer
New Contributor III

Hi all,

I have set up a script to take advantage of the new softwareupdate --fetch-full-installer command. If you're not aware this will download the latest macOS installer into the applications folder. It will then run a startosinstaller command to wipe and reinstall the OS. I have linked this in self service to make a 1 click reimage. I have tested this on a DEP enabled machine and it works perfectly!

I want to do the same for my non-DEP machines so I have added the --installpackage to the startosintaller line that should install a quickadd and DEP-Notify then get picked up on completed enrollment trigger to start DEP Notify.

The issue im having is that the software update command is downloading macOS High Sierra instead of catalina. The laptop currently has catalina installed so im not sure why its downloading an older OS.

Has anyone experiencd this issue? I have also specified version 10.15 but it just fails. Running the command in terminal has the same result.

!/bin/bash

macOS Erase and Reinstall Script for Non-DEP computers

macOSVersion=$(defaults read /Applications/Install macOS Catalina.app/Contents/Info.plist CFBundleShortVersionString)

CurrentVersion=15.1.03

if [[ -d /Applications/Install macOS Catalina.app ]] && [[ "$macOSVersion" == "$CurrentVersion" ]]; then

echo "macOS is cached and ready to install" > /Library/logs/Erase and Install.log

else

echo "Downloading latest macOS..." > /Library/logs/Erase and Install.log softwareupdate --fetch-full-installer

fi

echo "Wiping and installing"

/Applications/Install macOS Catalina.app/Contents/Resources/startosinstall --eraseinstall --agreetolicense --installpackage "Quickadd.app" --forcequitapps --newvolumename 'Macintosh HD'

Thanks James

0 REPLIES 0