URL without trailing forward slash apiUsername=“${4}" # API Username apiPasswordEncrypted=“${5}" # API Encrypted Password eaName=“${6}" # Name of Extension Attribute (i.e., "Testing Level") eaValue=“${7}" # Value for Extension Attribute (i.e., "Gamma" or "None") Salt="Salt goes here" # Salt, generated from Encrypt Password Passphrase="Passphrase goes here” # Passphrase, generated from Encrypt Password computerUUID=$( /usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/Hardware UUID:/ { print $3 }' ) ###################################### No edits needed below this line ###################################### Script: Extension Attribute Update.bash GitHub.com/dan-snelson # Read current value ... apiRead=$( /usr/bin/curl -H "Accept: text/xml" -sfu ${apiUsername}:${apiPassword} ${apiURL}/JSSResource/ computers/udid/${computerUUID}/subset/extension_attributes | /usr/bin/xmllint --format - | /usr/bin/grep -A3 "<name>${eaName}</name>" | /usr/bin/awk -F'>|<' '/value/{print $3}' ) /bin/echo "* Extension Attribute ${eaName}'s Current Value: ${apiRead}" # Construct the API data ... apiData="<computer><extension_attributes><extension_attribute><name>${eaName}</name><value>${eaValue}</ value></extension_attribute></extension_attributes></computer>" apiPost=$( /usr/bin/curl -H "Content-Type: text/xml" -sfu ${apiUsername}:${apiPassword} ${apiURL}/JSSResource/ computers/udid/${computerUUID} -d "${apiData}" -X PUT ) /bin/echo ${apiPost} # Read the new value ... apiRead=$( /usr/bin/curl -H "Accept: text/xml" -sfu ${apiUsername}:${apiPassword} ${apiURL}/JSSResource/ computers/udid/${computerUUID}/subset/extension_attributes | /usr/bin/xmllint --format - | /usr/bin/grep -A3 "<name>${eaName}</name>" | /usr/bin/awk -F'>|<' '/value/{print $3}' ) /bin/echo "* Extension Attribute ${eaName}'s New Value: ${apiRead}"