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.

  • 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

Before you can run a script, the script must exist in the Jamf Pro database. Scripts are automatically added to the database after they are added to Jamf Pro or Jamf Admin.

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.

  1. In Jamf Pro, click Settings in the top-right corner of the page.
  2. In the Computer Management section, click Scripts .
  3. Click New .
  4. 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.

  5. 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.
  6. Click the Options tab and configure additional settings for the script, including the priority.
  7. (Optional) Click the Limitations tab and configure operating system requirements for the script.
  8. Click Save .

Adding a Script to Jamf Admin

Adding a script to Jamf Admin adds the script to the Jamf Pro database and to Jamf Pro.

Requirements

To add a script to Jamf Admin, the script file must be non-compiled and in one of the following formats:

  • Perl (.pl)1

  • Bash (.sh)

  • Shell (.sh)

  • Non-compiled AppleScript (.applescript)

  • C Shell (.csh)

  • Zsh (.zsh)

  • Korn Shell (.ksh)

  • Tool Command Language (.tcl)

  • Hypertext Preprocessor (.php)3

  • Ruby (.rb)1

  • Python (.py)12

1 These scripting runtimes are deprecated as of macOS 10.15. They may be removed in a future version of macOS. To avoid issues, we recommended either using alternative scripting runtimes or deploying and managing your own runtimes on managed computers.

2 macOS 12 automatically installs Python 2.7 for compatibility purposes. However, when using Jamf Pro to execute scripts that call on Python on computers running macOS 12, users may be presented with an alert stating that Jamf needs to be updated.

3 Hypertext Preprocessor (.php) is not installed by default on computers with macOS 12 or later.

  1. Open Jamf Admin and authenticate to the Jamf Pro server.
  2. 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.

  3. Double-click the script in the main repository.
  4. Click the General tab and configure basic settings for the script, including the display name and category.
  5. Click the Options tab and configure additional settings for the script, including the priority and parameter labels.
  6. Click OK.

The script is now added to Jamf Pro and the Jamf Pro database.

Editing or Deleting a Script Using Jamf Admin

  1. Open Jamf Admin and authenticate to the Jamf Pro server.
  2. In the main repository, select the script you want to edit or delete.
  3. 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.

The edit or delete action is applied immediately.

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.

  1. In Jamf Pro, click Computers at the top of the sidebar.
  2. Click Policies in the sidebar.
  3. Click New .
  4. Use the General payload to configure basic settings for the policy, including the trigger and execution frequency.
  5. Select the Scripts payload and click Configure.
  6. Click Add for the script you want to run.
  7. Configure the settings for the script.
  8. Use the Restart Options payload to configure settings for restarting computers.
  9. Click the Scope tab and configure the scope of the policy.
  10. (Optional) Click the Self Service tab and make the policy available in Self Service.
  11. (Optional) Click the User Interaction tab and configure messaging and deferral options.
  12. 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.