---
title: "Run a Powershell script via Automate Joe"
slug: "powershell-automate-joe"
description: "You must place the Powershell scripts in a folder on the machine of the Automate Joe agent."
updated: 2022-09-20T14:26:59Z
published: 2022-09-20T14:26:59Z
canonical: "documentation.sysaid.com/powershell-automate-joe"
excludeFromSearch: true
excludeFromExternalSearch: true
---

> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.sysaid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run a Powershell script via Automate Joe

You can configure Automate Joe to automatically run Powershell scripts. For general information about setting up Automate Joe, see [Automate Joe](/v1/docs/automate-joe).

## Requirements

For the scripts to run:

- You must place the Powershell scripts in a folder on the machine of the Automate Joe agent. For example, C:\SysAidAJAddOns\Scripts. Note the location for use in the parameter mapping.
- The internal logic of any Powershell script that you want to run must be valid to be executed on the Automate Joe machine.
- The Automate Joe machine must have access to all resources that are referenced in the scripts.

## Parameter Mapping

The Automate Joe process named "Powershell - Execute Script” can support up to ten input parameters and five output parameters. Input parameter values can be taken from the SR, action item, or can be manually entered constants.

### Output Parameter Mapping

In order to return the exit code, last message, and output parameters back to SysAid, you need to map them like this:

![](https://cdn.document360.io/52d3cb6c-cc81-43c2-b6f7-cbabcb449271/Images/Documentation/OutgoingParameterMapping.png)

You can also create custom columns in the Action Item entity specifically for Exit Code (text) and Last Message (Text Area), if you do not want to use out-of-the-box custom fields.

## Scripting Hint

To access input parameters from within a script you would use the $args[X] expression, where X is a parameter index from 0 to 9, e.g.:

$Name = $args[0]

To return output parameters you would use the Write-Output "out_param_0X@@#@@V” expression, where X is a parameter index from 1 to 5 and V is the value for the parameter, e.g.:

Write-Output "out_param_01@@#@@1"

Also, it is possible to return a message from a script by using the following expression, e.g. for a “Finished Successfully” message:

Write-Output "process_last_message@@#@@Finished Successfully"

To run a script successfully, there should always be an output for the process_exit_code parameter with value of zero at the end:

Write-Output "process_exit_code@@#@@0"

The typical skeleton of a script would look like this:

try {

$ps code here

Write-Output "out_param_01@@#@@0"

Write-Output "process_last_message@@#@@Finished Successfully"

} catch {

Write-Output "out_param_01@@#@@1"

Write-Output "process_last_message@@#@@$($_)"

}

Write-Output "process_exit_code@@#@@0"
