Skip to main content

Huntress Agent (Reinstall)

Summary

This task reinstalls the Huntress Agent.

Create Script

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

Image
Image

Name: Huntress Agent (ReInstall)
Description: This task reinstalls the Huntress Agent.
Category: Custom

Image

Script

Row 1 Function: Script Log

Image

Input the following:

The script will detect the required keys for the Huntress reinstallation:

Bash Script

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 dropdown
  • 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 dropdown
  • 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 dropdown
  • Click Save

Image

Row 5 Function: PowerShell Script

Image

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

PowerShell Script

Image

Step 6 Function: Script Log

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

Image
Image

Step 7 Logic: If/Then

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

Image

Row 7a Condition: Output Contains

  • Type denied in the Value box.
  • Add another condition with the OR operator and type ERROR: in the Value box.
  • Add another condition with the OR operator and type Account Key Missing in the Value box.

Image

Row 7b Function: Script Exit

  • Add a new row in the If Section of the If-Else block by clicking the Add Row button
  • Search and select the Script Exit function.
  • Input the following
Failed to repair Huntress Agent. Command Result: %Output%

Image
Image

Step 8 Function: Script Log

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

Image
Image

Step 9 Function: Script Exit

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

Image
Image

Step 10: Complete Script

Image

Script Deployment

For now, the task has been created to run manually on the machines.

Go to Automations > Tasks.
Search for Huntress Agent (ReInstall).
Then click on Schedule and provide the parameters details as necessary for the script completion.

Image

Output

  • Script log

Changelog

2025-04-10

  • Initial version of the document