Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Created March 8, 2019 13:22
Show Gist options
  • Select an option

  • Save talkingmoose/7e8c58f23338e2a536c3f6ed77053620 to your computer and use it in GitHub Desktop.

Select an option

Save talkingmoose/7e8c58f23338e2a536c3f6ed77053620 to your computer and use it in GitHub Desktop.
Sample script for sending a remote management command to multple Macs via the Jamf Pro API.
#!/bin/bash
# server connection information
URL="https://talkingmoose.jamfcloud.com"
userName="api-editor"
password="P@55w0rd"
command="EnableRemoteDesktop" # or "DisableRemoteDesktop"
# XML data to upload
THExml="<computer_command>
<general>
<command>$command</command>
</general>
<computers>
<computer>
<id>4</id>
</computer>
<computer>
<id>7</id>
</computer>
</computers>
</computer_command>"
# flattened XML
flatXML=$( /usr/bin/xmllint --noblanks - <<< "$THExml" )
# API submission command
/usr/bin/curl "$URL/JSSResource/computercommands/command/$command" \
--user "$userName:$password" \
--header "Content-Type: text/xml" \
--request POST \
--data "$flatXML"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment