How to setup a Windows Agent to run Powershell jobs

Document ID : KB000088318
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:
How to setup a Windows Agent to run Powershell jobs.
 

Detailed Description and Symptoms

By default, Windows agents cannot run Powershell scripts unless it's through a .bat file or command that can be run from the Windows command line. Below are instructions on setting up Powershell as an interpreter for Windows agents. As of V11.1 of the Automation Engine, this can be set up globally, no configuration of individual agents is required.

Note:  All agents on which this feature is used must also be V11.1 or higher.

Resolution:

Configuration

In client 0, add a line to the variable UC_EXT_INTERPRETERS_WINDOWS in folder DIV_VARIABLES:

Key = POWERSHELL
Value 1 = .ps1
Value 2 = powershell.exe <FILE>

Ensure that the path to powershell.exe is included in the Windows PATH variable on all machines where Powershell scripts will be run.

If these are Agents upgraded in place (not new .ini files), please make sure the following lines are added in the global section:

ECPEXE=powershell.exe -NonInteractive -ExecutionPolicy bypass -NoLogo -file 
ECPEXT=ps1 

In versions before 11, the default for both parameters will be blank:

ECPEXE=
ECPEXT=


Usage

Use the following statements in the Process tab of a Windows job in order to use the Powershell interpreter:

:BEGIN_EXT_INTERPRETER POWERSHELL
... arbitrary Powershell commands ...
:END_EXT_INTERPRETER POWERSEHELL