Created
April 9, 2019 20:32
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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