3.1.8.2. Agent Scripts

An agent script will be executed on the hosts that match a certain policy. To create an agent script, go to ON CMDB > Agent > Agent Scripts. You will see the following configuration view:

../../../_images/flow-agentscript.png


All the scripts created to be running on an Agent are in this view. We can Add new, Edit, or Delete a script. To create an Agent script, we need the following information:

../../../_images/flow-agentscript-addnew.PNG


Type: You can select the language of the script.

../../../_images/flow-agentscript-addnew-type.png


There are three options: bash language for Linux and macOS, and powershell language.

Key: You can add the name of the script.

Processes that will execute the script: You can select the processes that will execute the script.

../../../_images/flow-agentscript-addnew-processes.png


Impersonate: You can choose whether the script will be executed by the system or only when the user is logged in when using the PowerShell script type. For the Bash type, this option is disabled.

Script: Code with the language we have selected.

../../../_images/flow-agentscript-addnew-example.png


For example, here there is a script that searches a file called LogDir in the path entered. The -ErrorAction Ignore is important to avoid problems when the file does not exist.