Created
June 27, 2022 04:39
-
-
Save talkingmoose/22f749726318b7523d52259c7b0f4302 to your computer and use it in GitHub Desktop.
Programmatic method to change a Jamf Pro server's Activation Code via the Classic API for Jamf Pro 10.35.0 and later.
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/zsh | |
# server connection information | |
URL="https://jss.talkingmoose.net:8443" | |
userName="JSSAPI-Editor" | |
password="password" | |
# use base64 to encode credentials | |
encodedCredentials=$( printf "$userName:$password" | iconv -t ISO-8859-1 | base64 -i - ) | |
# XML data to upload | |
THExml="<activation_code> | |
<organization_name>Talking Moose Industries</organization_name> | |
<code>V7OV-XDEU-DOBI-UDEU-7DEU-DOUD-QRUD-EGNR</code> | |
</activation_code>" | |
# flattened XML | |
flatXML=$( /usr/bin/xmllint --noblanks - <<< "$THExml" ) | |
# API submission command | |
/usr/bin/curl "$URL/JSSResource/activationcode" \ | |
--header "Content-Type: text/xml" \ | |
--header "Authorization: Basic $encodedCredentials" \ | |
--request PUT \ | |
--data "$flatXML" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment