Kandji Agent Command Line Interface

Learn how to interact with the Kandji Agent using its Command Line Interface (CLI)

While Kandji is primarily hands-off after it is installed on a Mac, a few Terminal commands are available.

Run

sudo kandji run

The agent will run and check-in immediately. Normally, the agent checks in every 15 minutes. Without an internet connection, the agent will run in offline mode.

sudo kandji run --reset-daily
Adding "--reset-daily" to the run command will run all parameters, including parameters that are only run once per day. For instance, if a parameter has already run earlier in the day, and only is enforced once a day

Run Daily MDM inventory update

sudo kandji update-mdm

The agent will request the MDM server to initiate its daily MDM commands such as validating Apps and Books from Apple Business Manager, as well as querying certain device information. 

Collect Apps

sudo kandji collect-apps

Collects full application inventory from the Mac.

Run Library Items 

sudo kandji library

Checks for Library items to execute. 

Additional library command options:

Option Description
--list List all of the Library items assigned to the computer.

--state

Get the current state of the Kandji Agent library manager.

--item

Run a specific library item, specify the name or library item ID, specify -F to force the execution. 

--cancel

Cancel the currently running library item and clears the current queue. 

Scriptable Option: Reboot

sudo kandji reboot --delaySeconds NumberOfSeconds

This option can be used in scripted workflows to easily force a reboot leveraging the Kandji Agent and Menu bar application, it is visually similar to the reboot forced during FileVault enablement or a Managed OS upgrade.

Initiates a restart by prompting the logged-in user with a countdown timer. If no delay is specified, the default 1800 (30 minutes) will be used. If no user is logged in, the delay will be ignored and the Mac will restart immediately.

Scriptable Option: Alert

sudo kandji display-alert [--title text] [--message text] [--icon path_to_image] [--suppression-key string] [--help-url url]

This option can be used in scripted workflows to easily present an alert to end users. This command has a multitude of options outlined below. All of the options below are optional. 

Option Description Default if not provided
--title Allows for specifying a custom title for the alert window "Alert"

--message

Allows for specifying a custom message for the alert window No default value

--icon

Allows for specifying a custom icon for the alert window KandjiAgent Icon

--suppression-key

If provided, will show an option to the end user "Do not show this message again" 

If this suppression key is provided in a future alert, and the user opted to not see it again, the alert will not be shown. 
No default value

If no Supression Key is specified the "Do not show this message again" option is not displayed. 
--help-url

Allows for specifying a custom URL for the alert "help" button.

Must be an https URL 

No default value

If no URL is specified the help button is not displayed. 

 

Below is an example of the alert on macOS Big Sur

Screen Shot 2020-12-10 at 11.40.19 AM

Version

sudo kandji version

Displays the installed Kandji Agent version.

Help

sudo kandji help

Displays help text.