Home > iOS, Jamf Pro, Jamf Pro API, Mac administration, macOS, Scripting > Backing up extension attributes from Jamf Pro

Backing up extension attributes from Jamf Pro

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:

  1. I have an off-server backup for the extension attributes
  2. I can track changes to the extension attributes

To help me manage this, I have two scripts which do the following:

  1. Use the Jamf Pro API to identify the Jamf Pro ID numbers of the extension attributes.
  2. Download each extension attribute as an XML file using its Jamf Pro ID number.
  3. Format the downloaded XML.
  4. Identify the display name of the extension attribute.
  5. Identify if it was a String, Integer or Date extension attribute.
  6. If it’s a macOS or Windows extension attribute and it has a script, extract the script.
  7. 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.

Screen Shot 2018 12 19 at 9 52 02 PM

Screen Shot 2018 12 19 at 10 04 33 PM

The scripts are available below, and at the following addresses on GitHub:

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/Casper_Scripts/Jamf_Pro_Computer_Extension_Attribute_Download

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/Casper_Scripts/Jamf_Pro_Mobile_Device_Extension_Attribute_Download

Jamf_Pro_Computer_Extension_Attribute_Download.sh:

Jamf_Pro_Mobile_Device_Extension_Attribute_Download.sh:

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: