Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Created March 30, 2022 17:11
Show Gist options
  • Save talkingmoose/07ae935169e863b377c2290c40a660e0 to your computer and use it in GitHub Desktop.
Save talkingmoose/07ae935169e863b377c2290c40a660e0 to your computer and use it in GitHub Desktop.
Checks for an existing Jamf Connect license installed on a Mac and reports license details similar to Jamf Connects' About window.
#!/bin/zsh
# Try to read the com.jamf.connect.login.plist file for license information
licenseInfo=$( /usr/bin/defaults read /Library/Managed\ Preferences/com.jamf.connect.login LicenseFile 2> /dev/null | /usr/bin/base64 --decode )
# If the file doesn't exist, try to read the com.jamf.connect.plist file for license information
if [ "$licenseInfo" = "" ]; then
licenseInfo=$( /usr/bin/defaults read /Library/Managed\ Preferences/com.jamf.connect LicenseFile 2> /dev/null | /usr/bin/base64 --decode )
fi
# Return results to Jamf Pro
if [ "$licenseInfo" = "" ]; then
# No license file exists for Jamf Connect
echo "<result>No license</result>"
else
# read licensing information from found license file
licensedTo=$( /usr/bin/xpath -e '//key[text()="Name"]/following-sibling::string[1]/text()' 2> /dev/null ) <<< "$licenseInfo"
licenseKey=$( /usr/bin/xpath -e '//key[text()="LicenseKey"]/following-sibling::string[1]/text()' 2> /dev/null ) <<< "$licenseInfo"
dateIssued=$( /usr/bin/xpath -e '//key[text()="DateIssued"]/following-sibling::string[1]/text()' 2> /dev/null | /usr/bin/awk '{ print $1 }' ) <<< "$licenseInfo"
ExpiresOn=$( /usr/bin/xpath -e '//key[text()="ExpirationDate"]/following-sibling::string[1]/text()' 2> /dev/null | /usr/bin/awk '{ print $1 }' ) <<< "$licenseInfo"
numberOfSeats=$( /usr/bin/xpath -e '//key[text()="NumberOfClients"]/following-sibling::integer[1]/text()' 2> /dev/null ) <<< "$licenseInfo"
# Return license information to Jamf Pro
echo "<result>Licensed to: $licensedTo
License Key: $licenseKey
Date Issued: $dateIssued
Expires On: $ExpiresOn
Number of Seats: $numberOfSeats</result>"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment