Skip to content

Instantly share code, notes, and snippets.

@motionbug
Last active December 6, 2023 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motionbug/8bfc64af12843d3534a4078be5673edf to your computer and use it in GitHub Desktop.
Save motionbug/8bfc64af12843d3534a4078be5673edf to your computer and use it in GitHub Desktop.
macOS Onboarding
#!/bin/zsh
#################################################
# Date: 05.12.23
#
# version 1.0
# Written by: Rob Potvin | Senior Consulting Engineer | Jamf
#
# DESCRIPTION
# Enable or Disable macOS Onboarding within the currenly logged in user.
#
# REQUIREMENTS
# Jamf Pro 11.1
#
################################################
# HARDCODED VALUE FOR "stop_onboarding" IS SET HERE
stop_onboarding=""
# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4 AND, IF SO, ASSIGN TO "stop_onboarding"
if [ "$4" != "" ] && [ "$stop_onboarding" == "" ]; then
stop_onboarding=$4
fi
currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
uid=$(id -u "$currentUser")
if [ -z "$currentUser" -o "$currentUser" = "loginwindow" ]; then
echo "no user logged in, cannot proceed"
exit 1
fi
# convenience function to run a command as the current user
# usage:
# runAsUser command arguments...
runAsUser() {
if [ "$currentUser" != "loginwindow" ]; then
launchctl asuser "$uid" sudo -u "$currentUser" "$@"
else
echo "no user logged in"
# uncomment the exit command
# to make the function exit with an error when no user is logged in
# exit 1
fi
}
case $stop_onboarding in
"yes")
echo "You chose 'yes'."
# adding Preference to disable macOS Onboarding
runAsUser defaults write ~/Library/Preferences/com.jamfsoftware.selfservice.mac.plist com.jamfsoftware.selfservice.onboardingcomplete -bool true
;;
"reset")
echo "You chose 'reset'."
# adding Preference to enable macOS Onboarding
runAsUser defaults write ~/Library/Preferences/com.jamfsoftware.selfservice.mac.plist com.jamfsoftware.selfservice.onboardingcomplete -bool false
;;
*)
echo "Doing nothing since you set nothing"
exit 0
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment