How to create a Powershell Program Type and script

book

Article ID: 110237

calendar_today

Updated On:

Products

CA Automic Applications Manager (AM)

Issue/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.

Environment

Release:
Component: APPMGR

Resolution

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.

<Please see attached file for image>

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).

<Please see attached file for image>

JOB

<Please see attached file for image>

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'
 

Attachments

1558697558663000110237_sktwi1f5rjvs16izu.png get_app
1558697557000000110237_sktwi1f5rjvs16izt.png get_app
1558697555014000110237_sktwi1f5rjvs16izs.png get_app