51 lines
2.3 KiB
Bash
Executable File
51 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
##########################################################################
|
|
# Shellscript : enable ARD
|
|
# Autor : Andreas Vogel, NEXT Enterprise GmbH 2022
|
|
##########################################################################
|
|
######################### Variablen #####################################################
|
|
jamfpro_url="${4}"
|
|
if [[ $jamfpro_url = "" ]]; then
|
|
echo "ERROR URL variable is empty"
|
|
exit 1
|
|
fi
|
|
|
|
Credentials="${5}"
|
|
if [[ $Credentials = "" ]]; then
|
|
echo "ERROR no Credentials"
|
|
exit 1
|
|
fi
|
|
|
|
Admim_Account="${6}"
|
|
|
|
|
|
serial=$(ioreg -c IOPlatformExpertDevice -d 2 | awk -F\" '/IOPlatformSerialNumber/{print $(NF-1)}')
|
|
authToken=$(/usr/bin/curl "${jamfpro_url}/api/v1/auth/token" --silent --request POST --header "Authorization: Basic ${Credentials}")
|
|
|
|
if [[ $(/usr/bin/sw_vers -productVersion | awk -F . '{print $1}') -lt 12 ]]
|
|
then
|
|
api_token=$(/usr/bin/awk -F \" 'NR==2{print $4}' <<< "$authToken" | /usr/bin/xargs)
|
|
else
|
|
api_token=$(/usr/bin/plutil -extract token raw -o - - <<< "$authToken")
|
|
fi
|
|
|
|
response=$(curl -X GET "$jamfpro_url/JSSResource/computers/serialnumber/$serial" -H "accept: application/xml" -H "Authorization: Bearer ${api_token}")
|
|
|
|
id=$(echo $response | /usr/bin/awk -F'<id>|</id>' '{print $2}')
|
|
|
|
|
|
|
|
|
|
######################### Execute #######################################################
|
|
######################### API ###########################################################
|
|
curl -X POST "$jamfpro_url/JSSResource/computercommands/command/EnableRemoteDesktop/id/${id}" -H "accept: application/xml" -H "Authorization: Bearer ${api_token}"
|
|
|
|
######################### Script ########################################################
|
|
#/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -targetdisk / -configure -users $Admim_Account -access -on -privs -all -clientopts -setmenuextra -menuextra yes
|
|
#/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -targetdisk / -configure -users admin -access -on -privs -all
|
|
#/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -targetdisk / -configure -allowAccessFor -specifiedUsers -privs -all
|
|
#/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -targetdisk / -restart -agent -menu
|
|
|
|
|
|
# Hide Account
|
|
# dscl . create /Users/$Admim_Account IsHidden 1 |