Need a script to turn on "Teamviewer" in System Preferences > Security & Privacy > Screen recording?

Mouthbaten_1911
New Contributor III

Hello, I need to create a script to simply turn on the Teamviewer in Security & Privacy > Screen recording. Right now it's a manual process and we're trying to deploy Teamviewer host via Jamf. However the configuration policy that comes with Teamviewer host does not allow us to allow screen sharing. It gives the user the option to allow screen sharing and since we don't want the user to interact with anything, I'm looking for a script that can turn on Teamviewer in Screen recording in Security & privacy:

 

Zohaib24_0-1675288171558.png

 

1 ACCEPTED SOLUTION

mojo21221
Contributor II

@Mouthbaten_1911 Here is a script I created to deploy TeamViewer Host via Self Service or at enrollment. We push out PPPC config profiles to allow Accessibility and SystemPolicyAllFiles. User still needs to enable screen sharing. I find it works better than the other deployment guides as it will always push out the latest version... I have scrubbed the IDC, API token and computer name schema we use. but you can plug in yours from your TV management gui (or from parts of their guide. Also I made the custom ID as parameter 7 which will need to be entered when deploying the script.

#!/bin/zsh
function logmessage()   {
    if [ $? = 0 ] ; then
        echo "$1"
    else
        echo "$2"
        echo "Aborting script"
        cleanup
        exit 1
    fi
}
 
function cleanup()  {
    /bin/rm -Rf "$tempDirectory"
    logmessage "Removed temporary items." "Failed removing temporary items."
    /bin/rm -f "/Library/Application Support/JAMF/Waiting Room/TeamViewerHost-id********.pkg" && /bin/rm -Rf "/Library/Application Support/JAMF/Waiting Room/TeamViewerHost-id********.pkg.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."
}
 
 
choicesXML='<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerPriviledgedHelper</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerPriviledgedHelper</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerPriviledgedHelper</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhost</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhost</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhost</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostAgent</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostAgent</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostAgent</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostRestarter</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostRestarter</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostRestarter</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerAuthPlugin</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerAuthPlugin</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerAuthPlugin</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemotePrinting</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemotePrinting</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>0</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemotePrinting</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemoteAudioDriver</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemoteAudioDriver</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemoteAudioDriver</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostSilentInstaller</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostSilentInstaller</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostSilentInstaller</string>
    </dict>
</array>
</plist>'
 
 
# 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'."
 
#Download and Install custom host
echo "Downloading and Installing TeamViewer custom host..."

waitingroomDirectory=$( mkdir "/Library/Application Support/JAMF/Waiting Room" )
cd "/Library/Application Support/JAMF/Waiting Room"
curl -L https://download.teamviewer.com/download/version_15x/CustomDesign/Install%20TeamViewerHost-$7.pkg -o "/Library/Application Support/JAMF/Waiting Room/TeamViewerHost-$7.pkg"
/usr/sbin/installer -pkg "/Library/Application Support/JAMF/Waiting Room/TeamViewerHost-id********.pkg" -applyChoiceChangesXML "$tempDirectory/choices.xml" -target /

cleanup

sleep 20

SERIAL=`ioreg -l | awk '/IOPlatformSerialNumber/ { print $4;}' | sed -e 's/^\"//' -e 's/"$//'`
/Applications/TeamViewerHost.app/Contents/Helpers/TeamViewer_Assignment -api-token ********************** -group Host_DeviceGroup -alias COMPUTER_NAME_GOES_HERE -grant-easy-access

exit 0

 here is the script for Teamviewer full

#!/bin/zsh
function logmessage()   {
    if [ $? = 0 ] ; then
        echo "$1"
    else
        echo "$2"
        echo "Aborting script"
        cleanup
        exit 1
    fi
}
 
function cleanup()  {
    /bin/rm -Rf "$tempDirectory"
    logmessage "Removed temporary items." "Failed removing temporary items."
    /bin/rm -Rf "/Library/Application Support/JAMF/Waiting Room/"
    logmessage "Removed TeamViewer package and supporting files from Jamf Waiting Room." "Failed Removing TeamViewer package and supporting files from Jamf Waiting Room."
}
 
 
choicesXML='<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerPriviledgedHelper</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerPriviledgedHelper</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerPriviledgedHelper</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewer</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewer</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewer</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAgent</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAgent</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAgent</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRestarter</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRestarter</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRestarter</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAuthPlugin</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAuthPlugin</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAuthPlugin</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemotePrinting</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemotePrinting</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>0</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemotePrinting</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemoteAudioDriver</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemoteAudioDriver</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemoteAudioDriver</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerSilentInstaller</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerSilentInstaller</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerSilentInstaller</string>
	</dict>
</array>
</plist>'
 
 
# 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'."

#Download and Install custom
echo "Downloading and Installing TeamViewer custom..."

waitingroomDirectory=$( mkdir "/Library/Application Support/JAMF/Waiting Room" )
cd "/Library/Application Support/JAMF/Waiting Room"
curl -L https://download.teamviewer.com/download/version_15x/CustomDesign/Install%20TeamViewer-$7.pkg -o "/Library/Application Support/JAMF/Waiting Room/TeamViewerFull-$7.pkg"
/usr/sbin/installer -pkg "/Library/Application Support/JAMF/Waiting Room/TeamViewerFull-id********.pkg" -applyChoiceChangesXML "$tempDirectory/choices.xml" -target /

logmessage "Installed TeamViewer package with choices." "Failed to install TeamViewer package with choices."
 
cleanup

sleep 30
SERIAL=`ioreg -l | awk '/IOPlatformSerialNumber/ { print $4;}' | sed -e 's/^\"//' -e 's/"$//'`
/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Assignment -api-token ****************** -group AdminFullClientGroup -alias COMPUTER_NAME_HERE
#/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Assignment -api-token ****************** -reassign -group AdminFullClientGroup -alias COMPUTER_NAME_HERE
 
exit 0

  

View solution in original post

11 REPLIES 11

nelsoni
Contributor III

This is not possible. Apple has made Screen Recording function in the same way that Mic and camera access works in that only the user can allow access. Apple did add one additional kink to screen recording in that you will have to deploy a PPPC profile to allow standard users to enable screen recording if they are not an admin on the device.

Yes but the user would still have to "Allow" screen recording when the connection attempt is made via Teamviewer. Is there nothing that can be done so the user doesn't have to do anything? 

Correct, Only the user can allow screen recording. Once they allow it it is good, but this is also a per user setting so each user that uses the mac will have to allow it.

So there is no way to Script "ALLOW" Screen Recording. You have to log on to every device you want to use unatteneded as an Admin and select "ALLOW"  Screen Recording?

From everything I have seen yes. Apple has yet to make an MDM profile payload that allows you to turn on screen recording. Same with mic and camera access

dmichels
Contributor II

https://docs.jamf.com/10.41.0/jamf-pro/documentation/TeamViewer_Integration.html?hl=teamviewer

https://www.youtube.com/watch?v=hwdVTJWPDO8 (this talks about using QuickStart and Jamf Pro to setup TeamViewer, not Host) but very good

dmichels
Contributor II

But isn't one of the main reasons to install "HOST" is to have access to all of your devices 24/7 and especially computer labs computers that are unattended?

 

TeamViewer Host-allows for unattended 24/7 access to machine and requires TeamViewer App to installed locally on machine

This is correct, once an admin of the machine has allowed screen recording on the device, then you can access it 24/7 unattended, but it must first be allowed by a user

Yes that's true, but once it's mass deployed, it leaves it up to the user to Allow screen sharing. So the user must allow that instead of the Teamviewer host's PPPC Profile. 

bwoods
Valued Contributor

Welcome to the wonderful world of macOS where you have to bend to Apple's will. All you can do is be transparent with your user base.

mojo21221
Contributor II

@Mouthbaten_1911 Here is a script I created to deploy TeamViewer Host via Self Service or at enrollment. We push out PPPC config profiles to allow Accessibility and SystemPolicyAllFiles. User still needs to enable screen sharing. I find it works better than the other deployment guides as it will always push out the latest version... I have scrubbed the IDC, API token and computer name schema we use. but you can plug in yours from your TV management gui (or from parts of their guide. Also I made the custom ID as parameter 7 which will need to be entered when deploying the script.

#!/bin/zsh
function logmessage()   {
    if [ $? = 0 ] ; then
        echo "$1"
    else
        echo "$2"
        echo "Aborting script"
        cleanup
        exit 1
    fi
}
 
function cleanup()  {
    /bin/rm -Rf "$tempDirectory"
    logmessage "Removed temporary items." "Failed removing temporary items."
    /bin/rm -f "/Library/Application Support/JAMF/Waiting Room/TeamViewerHost-id********.pkg" && /bin/rm -Rf "/Library/Application Support/JAMF/Waiting Room/TeamViewerHost-id********.pkg.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."
}
 
 
choicesXML='<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerPriviledgedHelper</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerPriviledgedHelper</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerPriviledgedHelper</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhost</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhost</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhost</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostAgent</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostAgent</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostAgent</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostRestarter</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostRestarter</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostRestarter</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerAuthPlugin</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerAuthPlugin</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerAuthPlugin</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemotePrinting</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemotePrinting</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>0</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemotePrinting</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemoteAudioDriver</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemoteAudioDriver</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerRemoteAudioDriver</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <false/>
        <key>choiceAttribute</key>
        <string>visible</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostSilentInstaller</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <true/>
        <key>choiceAttribute</key>
        <string>enabled</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostSilentInstaller</string>
    </dict>
    <dict>
        <key>attributeSetting</key>
        <integer>1</integer>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>choiceIdentifier</key>
        <string>com.teamviewer.teamviewerhostSilentInstaller</string>
    </dict>
</array>
</plist>'
 
 
# 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'."
 
#Download and Install custom host
echo "Downloading and Installing TeamViewer custom host..."

waitingroomDirectory=$( mkdir "/Library/Application Support/JAMF/Waiting Room" )
cd "/Library/Application Support/JAMF/Waiting Room"
curl -L https://download.teamviewer.com/download/version_15x/CustomDesign/Install%20TeamViewerHost-$7.pkg -o "/Library/Application Support/JAMF/Waiting Room/TeamViewerHost-$7.pkg"
/usr/sbin/installer -pkg "/Library/Application Support/JAMF/Waiting Room/TeamViewerHost-id********.pkg" -applyChoiceChangesXML "$tempDirectory/choices.xml" -target /

cleanup

sleep 20

SERIAL=`ioreg -l | awk '/IOPlatformSerialNumber/ { print $4;}' | sed -e 's/^\"//' -e 's/"$//'`
/Applications/TeamViewerHost.app/Contents/Helpers/TeamViewer_Assignment -api-token ********************** -group Host_DeviceGroup -alias COMPUTER_NAME_GOES_HERE -grant-easy-access

exit 0

 here is the script for Teamviewer full

#!/bin/zsh
function logmessage()   {
    if [ $? = 0 ] ; then
        echo "$1"
    else
        echo "$2"
        echo "Aborting script"
        cleanup
        exit 1
    fi
}
 
function cleanup()  {
    /bin/rm -Rf "$tempDirectory"
    logmessage "Removed temporary items." "Failed removing temporary items."
    /bin/rm -Rf "/Library/Application Support/JAMF/Waiting Room/"
    logmessage "Removed TeamViewer package and supporting files from Jamf Waiting Room." "Failed Removing TeamViewer package and supporting files from Jamf Waiting Room."
}
 
 
choicesXML='<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerPriviledgedHelper</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerPriviledgedHelper</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerPriviledgedHelper</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewer</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewer</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewer</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAgent</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAgent</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAgent</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRestarter</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRestarter</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRestarter</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAuthPlugin</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAuthPlugin</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerAuthPlugin</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemotePrinting</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemotePrinting</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>0</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemotePrinting</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemoteAudioDriver</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemoteAudioDriver</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerRemoteAudioDriver</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<false/>
		<key>choiceAttribute</key>
		<string>visible</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerSilentInstaller</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<true/>
		<key>choiceAttribute</key>
		<string>enabled</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerSilentInstaller</string>
	</dict>
	<dict>
		<key>attributeSetting</key>
		<integer>1</integer>
		<key>choiceAttribute</key>
		<string>selected</string>
		<key>choiceIdentifier</key>
		<string>com.teamviewer.teamviewerSilentInstaller</string>
	</dict>
</array>
</plist>'
 
 
# 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'."

#Download and Install custom
echo "Downloading and Installing TeamViewer custom..."

waitingroomDirectory=$( mkdir "/Library/Application Support/JAMF/Waiting Room" )
cd "/Library/Application Support/JAMF/Waiting Room"
curl -L https://download.teamviewer.com/download/version_15x/CustomDesign/Install%20TeamViewer-$7.pkg -o "/Library/Application Support/JAMF/Waiting Room/TeamViewerFull-$7.pkg"
/usr/sbin/installer -pkg "/Library/Application Support/JAMF/Waiting Room/TeamViewerFull-id********.pkg" -applyChoiceChangesXML "$tempDirectory/choices.xml" -target /

logmessage "Installed TeamViewer package with choices." "Failed to install TeamViewer package with choices."
 
cleanup

sleep 30
SERIAL=`ioreg -l | awk '/IOPlatformSerialNumber/ { print $4;}' | sed -e 's/^\"//' -e 's/"$//'`
/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Assignment -api-token ****************** -group AdminFullClientGroup -alias COMPUTER_NAME_HERE
#/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Assignment -api-token ****************** -reassign -group AdminFullClientGroup -alias COMPUTER_NAME_HERE
 
exit 0