Skip to content

Instantly share code, notes, and snippets.

  • Star 4 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/f2fbca97b3b5b58d4192be1e2f326eff to your computer and use it in GitHub Desktop.
Sample script for sending a remote management command to multple iOS devices via the Jamf Pro API.
#!/bin/bash
# server connection information
URL="https://talkingmoose.jamfcloud.com"
userName="api-editor"
password="P@55w0rd"
command="UpdateInventory"
# XML data to upload
THExml="<mobile_device_command>
<general>
<command>$command</command>
</general>
<mobile_devices>
<mobile_device>
<id>4</id>
</mobile_device>
<mobile_device>
<id>7</id>
</mobile_device>
<mobile_device>
<id>12</id>
</mobile_device>
</mobile_devices>
</mobile_device_command>"
# flattened XML
flatXML=$( /usr/bin/xmllint --noblanks - <<< "$THExml" )
# API submission command
/usr/bin/curl "$URL/JSSResource/mobiledevicecommands/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