Skip to content

Instantly share code, notes, and snippets.

@stevewood-tx
Created August 30, 2021 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevewood-tx/8ade3c4133fe0fcdc853bc7be10f9436 to your computer and use it in GitHub Desktop.
Save stevewood-tx/8ade3c4133fe0fcdc853bc7be10f9436 to your computer and use it in GitHub Desktop.
Upload Log to Jamf
## upload log to JPS
xpath() {
# the xpath tool changes in Big Sur
if [[ $(sw_vers -buildVersion) > "20A" ]]; then
/usr/bin/xpath -e "$@"
else
/usr/bin/xpath "$@"
fi
}
apiUser=''
apiPass=''
jpsURL=""
serial=$(system_profiler SPHardwareDataType | awk '/Serial\ Number\ \(system\)/ {print $NF}');
## get ID of computer
JSS_ID=$(curl -H "Accept: text/xml" -sfku "${apiUser}:${apiPass}" "${jpsURL}/JSSResource/computers/serialnumber/${serial}/subset/general" | xpath /computer/general/id | awk -F'>|<' '{print $3}')
curl -sku $apiUser:$apiPass $jpsURL/JSSResource/fileuploads/computers/id/$JSS_ID -F name=@${logFile} -X POST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment