Skip to main content

Huntress Agent (INSTALL)

Summary​

Installs the Huntress agent on the Windows machine if it's not already installed.

Dependencies​

Create Script​

Please create a new "PowerShell" style script to implement this script.

Image
Image

Name: Huntress Agent Install
Description: This task will check first if Huntress is installed. If not, it attempts to install the agent and log the result.
Category: Custom

Image

Script​

Row 1 Function: Script Log​

Image

Input the following:

Bash Script 1

Row 2 Function: Set Pre-defined Variable​

  • Select Set Pre-Defined Variable Function

Image

  • Select Custom Field
  • Input acct_key as Variable name
  • Select Huntress Acct_Key custom field from the drop-down
  • Click Save

Image

Row 3 Function: Set Pre-defined Variable​

  • Select Set Pre-Defined Variable Function

Image

  • Select Custom Field
  • Input ORG_Key as Variable name
  • Select Huntress Org_Key custom field from the drop-down
  • Click Save

Image

Row 4 Function: Set Pre-defined Variable​

  • Select Set Pre-Defined Variable Function

Image

  • Select Custom Field
  • Input Tags as Variable name
  • Select Huntress Tag custom field from the drop-down
  • Click Save

Image

Row 5 Function: PowerShell Script​

Image

Paste in the following PowerShell script and set the expected script execution time to 1500 seconds.

PowerShell Script

Image

Step 6 Function: Script Log​

  • Add a new row in the If Section of the If-Else part by clicking the Add Row button
  • Search and select the Script Log function.
  • Input the following

Bash Script 2

Image
Image

Step 7 Logic: If Then Else​

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

Image

ROW 7a Condition: Output Contains​

  • Type Huntress agent is installed in the Value box.

Image

ROW 7b Function: Set Custom Field​

  • Add a new row in the If Section of the If-Else part by clicking the Add Row button
  • Search and select the Set Custom Field function.

Image

  • Search and select the Huntress Deploy_Result Custom Field.
  • Type Successfully Installed in the Value box and click the Save button.

Image

ROW 7c Function: Script Log​

  • Add a new row in the If Section of the If-Else part by clicking the Add Row button
  • Search and select the Script Exit function.
  • Leave it blank

Bash Script 3

Image
Image

ROW 7d Function: Script Exit​

  • Add a new row in the If Section of the If-Else part by clicking the Add Row button
  • Search and select the Script Exit function.
  • Leave it blank

Image
Image

Step 7e Logic: If/Then​

Add a new If/Then logic from the Add Logic dropdown menu inside the Else section.

Image

Row 7e(i) Condition: Output Contains​

  • Select Output from the drop-down
  • Type ERROR: in the Value box.
  • Select another condition with the OR Operator
  • Type Account Key Missing in the Value box.

Image

Row 7e(ii) Function: Set Custom Field​

Add another row by selecting the ADD ROW button in the Else section of the internal If/Then section.

  • Search and select the Set Custom Field function.

Image

  • Search and select the Huntress Deploy_Result Custom Field.
  • Type %Output% in the Value box and click the Save button.

Image

Row 7e(iii) Function: Script Exit​

Add another row by selecting the ADD ROW button in the Else section of the internal If/Then section.

  • Search and select the Script Exit function.
  • Input the following

Bash Script 4

The final task should look like the screenshot below.

Image

Script Deployment​

This task has to be scheduled on the Deploy Huntress group for auto deployment. The script can also be run manually if required.

Go to Automations > Tasks.
Search for Huntress Agent Install.
Then click on Schedule and provide the parameter details as necessary for the script completion.

Image

Output​

  • Script log

FAQ​

Note:
For the Huntress deployment, the Huntress_Acct_Key is mandatory to be filled at the company level.

Image

The other custom fields can be left blank.

Note:
Huntress_Acct_Key and Huntress_Org_Key are the company custom fields, whereas the Huntress_Tags is the site-level custom field.

Changelog​

2025-04-10​

  • Initial version of the document