How to create a Powershell Program Type and script

Document ID : KB000110237
Last Modified Date : 13/08/2018
Show Technical Document Details
Introduction:
A Windows Powershell Program Type is not included in Applications Manager by default. This article details the steps to create a basic Program Type and Program Type script to run Powershell Jobs.
Instructions:
1. Create 2 Program Type Scripts and place them in the %AW_HOME%\exec directory. The scripts should be as follows:

ps_script.bat

call %SQLOPER_HOME%\bin\oneline %SQLOPER_HOME%\run\%par%
call %SQLOPER_HOME%\c\ntspawn "%SQLOPER_HOME%\exec\callps.bat"
if not %errorlevel% == 0 set err=%errorlevel%

callps.bat

powershell -NonInteractive -ExecutionPolicy bypass -NoLogo -file %program% %args%

Script names can be changed accordingly.

2. Create the Program Type object.

Program Type

Parameter format and Program Type Name can be changed accordingly. More information on defining a Program Type can be found at the documentation linked below:
3. Create a simple test Powershell script and place in the %AW_HOME%\exec directory. Below is a simple script to echos out 2 parameters:

test.ps1

echo $args[ 0 ]
echo $args[ 1 ]

4. Create Job with 2 Character Prompts (Job Name, Agent, Queue, script name can change accordingly).

JOB
Prompts

Below is an excerpt of a successful run of the Job.

C:\user_tests\PHM\AM9AGENT\run>powershell -NonInteractive -ExecutionPolicy bypass -NoLogo -file C:\user_tests\PHM\AM9AGENT\exec\test.ps1 Hello World
Hello
World
No error file found. [C:\user_tests\PHM\AM9AGENT\run\doserr.205.00]end of C:\user_tests\PHM\AM9AGENT\exec\BODY2.BAT status 0 Thu 08/09/2018 13:00:04.63
err is:'0'