Quantcast
Channel: rtrouton – Der Flounder
Viewing all articles
Browse latest Browse all 764

Backing up macOS scripts from Jamf Pro

$
0
0

When working with scripts for managing Macs on Jamf Pro, I prefer to download then and back them up to GitHub or a similar internal source control tool. The reason I do this is the following:

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

While I’ve usually had copies of the scripts stored elsewhere, sometimes I would make changes to the scripts on Jamf Pro and then not update the offline copy of the scripts with my changes. Being able to download them from my Jamf Pro server would mean that I could always have a copy of the latest version of the script in production.

To help me with this, I’ve written a script to do the following:

  1. Use the Jamf Pro API to identify the Jamf Pro ID numbers of the scripts.
  2. Download each script using its Jamf Pro ID number as raw XML.
  3. Format the downloaded XML
  4. Identify the display name of the script
  5. Extract the script from the downloaded XML
  6. Save the script as Display Name Goes Here to a specified download directory.

For more details, please see below the jump.

For authentication, the download script 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

To run the download script:

/path/to/Jamf_Pro_Computer_Script_Download.sh

When run, you should see output similar to that shown below.

Screen Shot 2018 12 07 at 10 17 02 PM

The downloaded scripts 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 07 at 10 17 09 PM

The download script is available below, and at the following address on GitHub:

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

Jamf_Pro_Computer_Script_Download.sh:


Viewing all articles
Browse latest Browse all 764

Trending Articles