-
-
Notifications
You must be signed in to change notification settings - Fork 39
Jamf API Tool
The jamf_api_tool.py
script can be used to list and provide details of API items based on a number of criteria. The criteria depends on the API objects being requested. Here are the available arguments:
-h, --help show this help message and exit
--computers
--policies
--packages
--scripts
--ea
--groups
-n NAMES, --name NAMES
Give a policy name to delete. Multiple allowed.
--os OS Restrict computer search to an OS version. Requires --computer
--search SEARCH List all policies that start with given query. Delete available in conjunction with --delete.
--category CATEGORY List all policies in given category. Delete available in conjunction with --delete.
--details Must be used with another search argument.
--unused Must be used with another search argument.
--delete Must be used with another search argument.
--all All Policies will be listed but no action will be taken. This is only meant for you to browse your JSS.
--slack Post a slack webhook
--url URL the Jamf Pro Server URL
--user USER a user with the rights to delete a policy
--password PASSWORD password of the user with the rights to delete a policy
--smb_url SMB_URL Path to an SMB FileShare Distribution Point, in the form smb://server/mountpoint
--smb_user SMB_USER a user with the rights to upload a package to the SMB FileShare Distribution Point
--smb_pass SMB_PASS password of the user with the rights to upload a package to the SMB FileShare Distribution Point
--prefs PREFS full path to an AutoPkg prefs file containing JSS URL, API_USERNAME and API_PASSWORD, for example an AutoPkg preferences file which
has been configured for use with JSSImporter (~/Library/Preferences/com.github.autopkg.plist) or a separate plist anywhere (e.g.
~/.com.company.jcds_upload.plist)
-v, --verbose print verbose output headers
Credentials are supplied either by specifying a preferences file (plist or json), or directly from the command line using the --url
, --user
and --password
parameters. If you do not supply any of these in arguments, you will be asked for them interactively. Optionally, if you intend to delete packages and are using an SMB-based FileShare Distribution Point, you can supply the SMB details in the preferences file or using the --smb_url
, --smb_user
and --smb_pass
parameters. If you supply the --smb_url
parameter but not the others, you will be asked for these details interactively.
To list all computers and show the last reported installed OS and how long ago the computer checked in, use the following command:
./jamf_api_tool.py --prefs /path/to/prefs.plist --computers --all
You can optionally restrict the search to a particular os:
./jamf_api_tool.py --prefs /path/to/prefs.plist --computers --all --os 10.15
To list all policies and show any associated package and/or scope, use the following command:
./jamf_api_tool.py --prefs /path/to/prefs.plist --policies --all
To search for policies matching a pattern, use the following command:
./jamf_api_tool.py --prefs /path/to/prefs.plist --policies --search "Microsoft Edge"
To search for and delete matching policies, add the --delete
parameter:
./jamf_api_tool.py --prefs /path/to/prefs.plist --policies --search "Microsoft Edge v80.0.361.54" --delete
To list all packages use the following command:
./jamf_api_tool.py --prefs /path/to/prefs.plist --packages --all
To list additional details about all packages use the following command (takes longer):
./jamf_api_tool.py --prefs /path/to/prefs.plist --packages --all --details
To identify (used and) unused packages, use the following command:
./jamf_api_tool.py --prefs /path/to/prefs.plist --packages --unused
To identify (used and) unused packages and start an interactive dialog for deleting the unused packages, use the following command:
./jamf_api_tool.py --prefs /path/to/prefs.plist --packages --unused --delete
The above commands can be substituted for Smart Groups, Extension Attributes, Scripts by replacing the --packages
parameter with --groups
, --ea
or --scripts
respectively.