While working with extension attributes on Jamf Pro, I prefer to download then and back them up to GitHub or a similar internal source control tool. The reasons I do this are the following:
- I have an off-server backup for the extension attributes
- I can track changes to the extension attributes
To help me manage this, I have two scripts which do the following:
- Use the Jamf Pro API to identify the Jamf Pro ID numbers of the extension attributes.
- Download each extension attribute as an XML file using its Jamf Pro ID number.
- Format the downloaded XML.
- Identify the display name of the extension attribute.
- Identify if it was a String, Integer or Date extension attribute.
- If it’s a macOS or Windows extension attribute and it has a script, extract the script.
- Save the downloaded XML or script as Extension Attribute Name Here to a specified download directory, based on whether it was a String, Integer or Date extension attribute.
For more details, please see below the jump.
I’ve written two scripts for this purpose:
- Jamf_Pro_Computer_Extension_Attribute_Download.sh – This script is designed to download and handle macOS extension attributes.
- Jamf_Pro_Mobile_Device_Extension_Attribute_Download.sh – This script is designed to download and handle iOS and tvOS extension attributes.
For authentication, the scripts can accept hard-coded values in the script, manual input or values stored in a ~/Library/Preferences/com.github.jamfpro-info.plist file. The plist file can be created by running the following commands and substituting your own values where appropriate:
To store the Jamf Pro URL in the plist file:
defaults write com.github.jamfpro-info jamfpro_url https://jamf.pro.server.goes.here:port_number_goes_here
To store the account username in the plist file:
defaults write com.github.jamfpro-info jamfpro_user account_username_goes_here
To store the account password in the plist file:
defaults write com.github.jamfpro-info jamfpro_password account_password_goes_here
Both scripts run in similar ways, with the main difference being which kind of extension attributes are being downloaded. One notable difference is that the macOS extension attributes may download scripts, while the iOS and tvOS extension attributes will only ever be XML files.
To download macOS extension attributes:
/path/to/Jamf_Pro_Computer_Extension_Attribute_Download.sh
To download iOS and tvOS extension attributes:
/path/to/Jamf_Pro_Mobile_Device_Extension_Attribute_Download.sh
When run, you should see output similar to that shown below (in this case, Jamf_Pro_Computer_Extension_Attribute_Download.sh is being run.)
The extension attributes themselves will be stored in either a user-specified directory or, if no directory is specified, a directory created by the script.
The scripts are available below, and at the following addresses on GitHub:
Jamf_Pro_Computer_Extension_Attribute_Download.sh:
Jamf_Pro_Mobile_Device_Extension_Attribute_Download.sh: