Skip to main content

Huntress Agent (Install) - MAC

Summary​

This task will first check if Huntress is installed. If it is not, the script will attempt to install the agent and log the result for MAC machines.

Note: Huntress Agent requires macOS 13.0.0 or later.

Create Script​

  • Go to Automation > Tasks
  • At the top-right corner, click on the Add dropdown menu and select Script Editor

Task Details:

  • Name: Huntress Agent (Install) - MAC
  • Description: This task will check if Huntress is installed. If not, it will attempt to install the agent and log the result for MAC machines.
  • Category: Custom

Image 3

Script​

Row 1 Function: Set Pre-defined Variable​

  • Select Set Pre-Defined Variable Function
    Image 5

  • Select Custom Field

  • Input acctKey as Variable name

  • Select Huntress Acct_Key or (Huntress Account Key) custom field from the dropdown

  • Click Save

Image 6

Row 2 Function: Set Pre-defined Variable​

  • Select Set Pre-Defined Variable Function
    Image 7

  • Select Custom Field

  • Input orgKey as Variable name

  • Select Huntress Org_Key custom field from the dropdown

  • Click Save

Image 8

Row 3 Function: Set Pre-defined Variable​

  • Select Set Pre-Defined Variable Function
    Image 9

  • Select Custom Field

  • Input tags as Variable name

  • Select Huntress Tag custom field from the dropdown

  • Click Save

Image 10

Row 4 Function: Script Log​

Image 4

Input the following:

The script will detect the Huntress Agent and if the agent is not found then it will install the agent.

acct_key : @acctKey@
org_key: @orgKey@
Tags: @tags@

Attempting to download the file using acct_key from the huntress website as below:

https://huntress.io/script/darwin/@acctKey@, and once downloaded the agent will be attempted to install.

Row 5 Function: Bash Script​

Image 11

Paste the following PowerShell script and set the expected script execution time to 900 seconds. Set this step to Continue on Failure

Bash Script 1

Image 12

Step 6 Function: Script Log​

  • Add a new row by clicking the Add Row button
  • Search and select the Script Log function.
  • Input the following:

Bash Script 2

Image 13
Image 14

Step 7 Logic: If/Then​

  • Add a new If/Then logic from the Add Logic dropdown menu.
    Image 15

Row 7a Condition: Output Contains​

  • Type Huntress agent is installed in the Value box.
    Image 16

Row 7b Function: Set Custom Field​

  • Add a new row in the If Section by clicking the Add Row button

  • Search and select the Set Custom Field function.
    Image 17

  • Search and select the Huntress Deploy_Result Custom Field.

  • Type Successfully Installed in the Value box and click the Save button.

Row 7c Function: Script Exit​

  • Add a new row in the If Section by clicking the Add Row button

  • Search and select the Script Exit function.

  • Leave the value blank to allow the script to exit on success.

    Image 18
    Image 19

Step 8 Function: Script Exit​

  • Add a new row after the If/Then Section by clicking the Add Row button
  • Search and select the Script Log function.
  • Input the following:

Bash Script 3

Image 20
Image 21

Completed Script​

Image 22

Script Deployment​

This task must be scheduled on Deploy Huntress - MAC, the group for auto-deployment. The script can also be run manually if required.

  • Go to Automations > Tasks.
  • Search for Huntress Agent (Install) - MAC.
  • Then click on Schedule and select the Target:

Image 23

Select the group "Deploy Huntress - MAC" and save the selection.

Image 24

Once selected, click on Run to schedule the script as per requirement.

Output​

  • Script log

Changelog​

2025-10-01​

  • The script was failing to install the Huntress Agent on MAC. Fixed the bug and updated the script to write the installation script instead of downloading it.

2025-04-10​

  • Initial version of the document