We use a thumb drive with a boot partition and an automator workflow that calls the following script to wipe our Macs. We use DEP for setups, so we just set them back to factory and let the end users go through the prestage enrollment. My test machine is a 2013 MacBook Air. I just recently started using a 2015 15" MacBook Pro for some testing. When I tried using this method on it, it always fails to set the startup disk, which causes the workflow to fail and doesn't restart the system. I can still manually restart and set the startup disk myself. With my limited knowledge of scripting, I have commented out the line "sudo systemsetup -setstartupdisk /Volumes/Macintosh HD" and this allows the workflow to finish, but then the startup disk isn't set, so it just boots to a ? folder.
Does anyone know why this method would be working fine on a 2013 MacBook Air but not the 2015 MacBook Pro?
!/bin/sh
CORESTORAGE=diskutil cs list | awk -F: '/Name:/{print $2;exit}'| sed -e 's/^[[:space:]]*//'
if [ "$CORESTORAGE" != "" ]; then
sudo diskutil cs delete "$CORESTORAGE"
sudo asr restore -s /Volumes/Storage/10.12.6-16G29.dmg -t /Volumes/Untitled --erase --noprompt
else
sudo asr restore -s /Volumes/Storage/10.12.6-16G29.dmg -t /Volumes/Macintosh HD --erase --noprompt
fi
sudo systemsetup -setstartupdisk /Volumes/Macintosh HD