Skip to content

Instantly share code, notes, and snippets.

Created May 5, 2023 15:33
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save talkingmoose/3926e86332e32eb7d05a161c3f7e8f69 to your computer and use it in GitHub Desktop.
This script when edited with the Apple Installer package name and app bundle identifier(s) will deploy a choices.xml file to exlude an installer choice during package installation.
Written by:William Smith
Partner Program Manager
Originally posted: May 5, 2023
Purpose: Deploys a Choices XML file for use with the specified Apple
Installer package.
1. Create a new script in Jamf Pro with the entirety of
this script.
2. Edit the installerPackage name on line 45 with the name of the
Apple installer package you're deploying.
3. Edit the app bundle identifier on line 59 with the CFBundleIdentifier
of the app you wish to prevent installing. To add a second app,
duplicate the entire dictionary ( from <dict> to </dict> )
and edit its choiceIdentifier string.
4. In a new Jamf Pro policy, add both the package and the script.
5. Set the package to Cache not Install.
6. Add any additional policy settings you need, scope, and deploy.
Except where otherwise noted, this work is licensed under
“A problem well stated is a problem half solved."
# provide the name of an Apple Installer package file that supports Choices XML
# modify the choiceIdentifier string with the app identifier (CFBundleIdentifier) to exclude from installation
# duplicate the full dictionary to include additiona apps
choicesXML='<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
function logmessage() {
if [ $? = 0 ] ; then
echo "$1"
echo "$2"
echo "Aborting script"
exit 1
function cleanup() {
/bin/rm -Rf "$tempDirectory"
logmessage "Removed temporary items." "Failed removing temporary items."
/bin/rm -f "/Library/Application Support/JAMF/Waiting Room/$installerPackage" && /bin/rm -Rf "/Library/Application Support/JAMF/Waiting Room/$installerPackage.cache.xml"
logmessage "Removed TeamViewer Host package and supporting files from Jamf Waiting Room." "Failed Removing TeamViewer Host package and supporting files from Jamf Waiting Room."
# create temporary working directory
workDirectory=$( /usr/bin/basename $0 )
tempDirectory=$( /usr/bin/mktemp -d "/private/tmp/$workDirectory.XXXXXX" )
logmessage "Created working directory '$tempDirectory'." "Failed to create working directory '$tempDirectory'."
# change directory to temporary working directory
cd "$tempDirectory"
logmessage "Changed directory to working directory '$tempDirectory'." "Failed to change directory to working directory '$tempDirectory'."
echo "$choicesXML" > "$tempDirectory/choices.xml"
logmessage "Created choices.xml file in '$tempDirectory'." "Created choices.xml file in '$tempDirectory'."
/usr/sbin/installer -pkg "/Library/Application Support/JAMF/Waiting Room/$installerPackage" -applyChoiceChangesXML "$tempDirectory/choices.xml" -target /
logmessage "Installed TeamViewerHost package with choices." "Failed to install TeamViewerHost package with choices."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment