Tag Archives: jamf

JamfReports Ruby Gem

Ruby Gem for Jamf Pro API

JamfReports is a ruby gem that uses the Jamf Pro API for hosted instances. Currently, it only reports on Applications. Pulling from the /api/v1/computers-inventory?section=APPLICATIONS endpoint.

For gem install instructions see here

*Future reports may be added.


Usage

In order to run JamfReports, you are required to add these two lines to the top of your file, under the require JamfReports line

#!/usr/bin/ruby
require "JamfReports"

## UPDATE THESE VARIABLES -------------------------------
$jamfpro_url = "https://company.jamfcloud.com" 
$api_pw = "Your API KEY HERE"

If you don’t have your api key for the $api_pw variable, run this command to create it and paste it into the variable.

printf "jamfUserName:JamfPassword" | iconv -t ISO-8859-1 | base64 -i -

And these 3 lines to generate the api token and pull the data from Jamf so you can run the report commands.

JamfReports.getToken
JamfReports.checkTokenExpiration
JamfReports.getAllApplicationInventory

A full working file might look like this.

#!/usr/bin/ruby
require "JamfReports"

## UPDATE THESE VARIABLES ----------------------------------------
$jamfpro_url = "https://company.jamfcloud.com" 
$api_pw = "Your API KEY HERE"

## COMMANDS ------------------------------------------------------
JamfReports.getToken
JamfReports.checkTokenExpiration
JamfReports.getAllApplicationInventory

## REPORTS -------------------------------------------------------
JamfReports.listAllInstalledApps
# JamfReports.webBrowserReport
# JamfReports.totalNumberOfOneInstalledApps
# JamfReports.listofOneInstallApps

## After reporting, revoke current token
JamfReports.invalidateToken

Examples

listAllInstalledApps

Returns a sorted list of all apps installed across your fleet of computers in Jamf. Sorted from most installed app, to least.

webBrowserReport

  • Google Chrome.app
  • Google Chrome Canary.app
  • Firefox.app
  • Firefox Developer Edition.app
  • Safari.app
  • Safari Technology Preview.app
  • Microsoft Edge.app
  • Brave Browser.app
  • Arc.app
  • Opera.app
  • LinCastor Browser.app
  • LockDown Browser.app
  • Tor Browser.app
  • Vivaldi.app
  • DuckDuckGo.app

totalNumberOfOneInstalledApps

Returns a single metric to show the number of “One-off” or single installed apps across your fleet.

listofOneInstallApps

Returns a list of all the “One-off” or single installed apps across your fleet. This can be helpful in scoping in Jamf uninstall policies.

Download a package from a Jamf Pro Cloud Distribution Point

I ran into a new issue. I have a policy that is pushing a package that I’m not clear on what it’s doing. What’s worse, the policy is pending or failed on a large number of machines. To confuse matters, I have 3 different “Google Chrome” packages but no idea what the differences are.

I wanted to download the packages and open them with something like Suspicious Package to see what they are actually doing.

Since there’s no “Download” option in Jamf for your pkg, and I don’t want to install the package to figure out if it’s working. You can create a policy, cache the package, scope it to your machine and then copy the package to your desktop.

  • Create a new policy
  • Add each package you want to download
  • Set the Action to Cache
  • I made the policy available in Self Service, so I wouldn’t have to wait for a check-in
  • Scope the policy to only your machine

After you install the packages. Open Terminal and switch to root. Change to the directory and verify the packages are downloaded.

sh-3.2# sudo su
sh-3.2# cd /Library/Application\ Support/JAMF/Waiting\ Room/
sh-3.2# ls -1

Now, let’s copy the packages (ignore the cache.xml files) to our desktop and change the owner to our account, so we can examine them.

#copy pkgs to your desktop
cp Google Chrome new.pkg /Users/username/Desktop/
cp Google Chrome.pkg /Users/username/Desktop/
cp googlechrome.pkg /Users/username/Desktop/

#change the owner from root, to your user account
chown username /Users/username/Desktop/Google Chrome new.pkg
chown username /Users/username/Desktop/Google Chrome.pkg
chown username /Users/username/Desktop/googlechrome.pkg

If all you needed to do was download the packages, you’re done! In my case, I want to see what they are installing, so I’ll open them with Suspicious Package.



This package, Google Chrome new.pkg is installing v89.04.4389.90! Maybe this was new at some point, but clearly poorly named now.

Turns out the package that was causing me the most issues was googlechrome.pkg which was trying to install Chrome to the System volume, instead of "/Applications“, which was causing it to fail on every client it was scoped to.