Created
March 8, 2019 13:22
-
-
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.
This file contains hidden or 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="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