Scripts
You can manage and run scripts in your environment by using Jamf Pro or Jamf Admin.
When you add a script to Jamf Pro or Jamf Admin, you can configure the following script settings:
-
Add the script to a category. For more information, see Categories.
-
Choose a priority for running the script during imaging.
-
Enter parameter labels.
-
Specify operating system requirements for running the script.
When you add, edit, or delete a script in Jamf Admin, the changes are reflected in Jamf Pro and vice versa.
Script Storage
How you manage your scripts depends on where they are stored. Consider the following storage options:
-
As data in the Jamf Pro database—Before you can run a script in this type of environment, the script must exist in the database. Scripts are automatically added to the database after they are added to Jamf Pro or Jamf Admin.
-
As files on your distribution points—Before you can run a script in this type of environment, the script must exist on the distribution point you plan to deploy it from and in Jamf Pro. You can add the script to the principal distribution point by adding it to Jamf Admin. Then you can add the script to other distribution points via replication.
For more information about migrating the scripts on your principal distribution point, see the Migrating Packages and Scripts Knowledge Base article.
Adding a Script to Jamf Pro
If your environment is one in which scripts are stored in the Jamf Pro database, you can add a script to Jamf Pro using the script editor.
-
Log in to Jamf Pro.
-
In the top-right corner of the page, click Settings
.
-
Click Computer Management.
-
In the “Computer Management” section, click Scripts
.
-
Click New
.
-
Use the General pane to configure basic settings for the script, including the display name and category.
Note: If you do not add the script to a category, Jamf Admin displays the script in blue text in the Unknown category.
-
Click the Script tab and enter the script contents in the script editor. You can use the settings on the tab to configure syntax highlighting and theme colors in the script editor.
-
Click the Options tab and configure additional settings for the script, including the priority.
-
(Optional) Click the Limitations tab and configure operating system requirements for the script.
-
Click Save
.
Adding a Script to Jamf Admin
Requirements
To add a script to Jamf Admin, the script file must be non-compiled and in one of the following formats:
-
Perl (.pl)
-
Bash (.sh)
-
Shell (.sh)
-
Non-compiled AppleScript (.applescript)
-
C Shell (.csh)
-
Zsh (.zsh)
-
Korn Shell (.ksh)
-
Tool Command Language (.tcl)
-
Hypertext Preprocessor (.php)
-
Ruby (.rb)
-
Python (.py)
Procedure
Adding a script to Jamf Admin adds the script to the Jamf Pro database or the principal distribution point, and to Jamf Pro.
-
Open Jamf Admin and authenticate to the Jamf Pro server.
-
Drag the script to the main repository in Jamf Admin.
The script is displayed in blue text in the Unknown category until you add it to a category. -
Double-click the script in the main repository.
-
Click the General tab and configure basic settings for the script, including the display name and category.
-
Click the Options tab and configure additional settings for the script, including the priority and parameter labels.
-
Click OK.
The script is now added to Jamf Pro and the Jamf Pro database or the principal distribution point.
Editing or Deleting a Script Using Jamf Admin
-
Open Jamf Admin and authenticate to the Jamf Pro server.
-
In the main repository, select the script you want to edit or delete.
-
Do one of the following:
-
To edit the script, double-click it and make changes as needed. Then click OK.
-
To delete the script, click Delete
, and then click Delete again to confirm.
-
If the script is stored in the Jamf Pro database, the edit or delete action is applied immediately.
If the script is stored on your distribution points, the edit or delete action is applied immediately on the principal distribution point. The action is applied to your other distribution points when replication occurs.
Running Scripts Using a Policy
When you run a script, you can choose a priority for running the script. You can also enter parameter values for the script.
Note: When running a script that contains HTML tags in the output, the tags are not rendered in policy logs.
Requirements
To run a script on computers, the script must be stored on the distribution point you plan to deploy it from and in Jamf Pro, or in the Jamf Pro database.
Procedure
-
Log in to Jamf Pro.
-
Click the Computers tab at the top of the page.
-
Click Policies.
-
Click New
.
-
Use the General payload to configure basic settings for the policy, including the trigger and execution frequency.
-
Select the Scripts payload and click Configure.
-
Click Add for the script you want to run.
-
Configure the settings for the script.
-
Use the Restart Options payload to configure settings for restarting computers.
-
Click the Scope tab and configure the scope of the policy.
For more information, see Scope. -
(Optional) Click the Self Service tab and make the policy available in Self Service.
For more information, see Items Available to Users in Jamf Self Service for macOS. -
(Optional) Click the User Interaction tab and configure messaging and deferral options.
For more information, see User Interaction with Policies. -
Click Save
.
The policy runs on computers in the scope the next time they check in with Jamf Pro and meet the criteria in the General payload.
Related Information
For related information, see the following sections in this guide:
-
About Policies
Learn the basics about policies. -
Policy Management
Find out how to create policies, view the plan and status for a policy, and view and flush policy logs.