Last active
November 21, 2023 22:31
-
-
Save talkingmoose/47f2aa8697587a7bdf42f99a86e64af1 to your computer and use it in GitHub Desktop.
Self Service policy to enable end users to enroll their Macs into an "Early Adopter Program" or any other type of enrollment. Create a Smart Computer Group to identify early adopters and scope policies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
enrollmentStatus=$( /usr/bin/defaults read '/Library/Preferences/EarlyAdopter.plist' Enrolled ) | |
echo "<result>$enrollmentStatus</result>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# get current day and time | |
timestamp=$( /bin/date ) | |
# get name of currently logged in user | |
currentUser=$( /usr/bin/stat -f '%Su' /dev/console ) | |
# get current enrollment status | |
enrollmentStatus=$( /usr/bin/defaults read '/Library/Preferences/EarlyAdopter.plist' Enrolled ) | |
# check enrollment status | |
if [ "$enrollmentStatus" = "Yes" ]; then | |
# display dialog to end user to unenroll a Mac | |
response=$( /Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Early Adopters Program" -heading "Enrollment Status" -description "This Mac is currently enrolled in the Early Adopters Program. | |
Click Unenroll to remove it from the program." -button1 "Unenroll" -button2 "Cancel" -icon '/System/Library/CoreServices/Software Update.app/Contents/Resources/SoftwareUpdate.icns' ) | |
if [ "$response" -eq 0 ]; then | |
# unenroll Mac from Early Adopter program and log the username and time | |
/usr/bin/defaults write '/Library/Preferences/EarlyAdopter.plist' Enrolled -string "No" | |
/usr/bin/defaults write '/Library/Preferences/EarlyAdopter.plist' Username -string "$currentUser" | |
/usr/bin/defaults write '/Library/Preferences/EarlyAdopter.plist' Date -string "$timestamp" | |
# update Jamf Pro inventory and enrollment status | |
/usr/local/bin/jamf recon | |
# display dialog to end user to confirm unenrollment | |
/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Early Adopters Program" -heading "Enrollment Status" -description "This Mac is was removed from the Early Adopters Program. | |
Return to Self Service at any time to reenroll." -button1 "OK" -defaultButton 1 -icon '/System/Library/CoreServices/Software Update.app/Contents/Resources/SoftwareUpdate.icns' -timeout 10 | |
echo "$currentUser unenrolled Mac from Early Adopter program." | |
fi | |
else | |
# display dialog to end user to enroll a Mac | |
response=$( /Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Early Adopters Program" -heading "Enrollment Status" -description "This Mac is not enrolled in the Early Adopters Program. | |
By clicking Enroll, you agree to test and provide feedback about newly installed software updates." -button1 "Enroll" -button2 "Cancel" -icon '/System/Library/CoreServices/Software Update.app/Contents/Resources/SoftwareUpdate.icns' ) | |
if [ "$response" -eq 0 ]; then | |
# enroll Mac into Early Adopter program and log the username and time | |
/usr/bin/defaults write '/Library/Preferences/EarlyAdopter.plist' Enrolled -string "Yes" | |
/usr/bin/defaults write '/Library/Preferences/EarlyAdopter.plist' Username -string "$currentUser" | |
/usr/bin/defaults write '/Library/Preferences/EarlyAdopter.plist' Date -string "$timestamp" | |
# update Jamf Pro inventory and enrollment status | |
/usr/local/bin/jamf recon | |
# display dialog to end user to confirm enrollment | |
/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Early Adopters Program" -heading "Enrollment Status" -description "This Mac is now enrolled in the Early Adopters Program. | |
Return to Self Service at any time to unenroll." -button1 "OK" -defaultButton 1 -icon '/System/Library/CoreServices/Software Update.app/Contents/Resources/SoftwareUpdate.icns' -timeout 10 | |
echo "$currentUser enrolled Mac into Early Adopter program." | |
fi | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment