How to create a Powershell Program Type and script
search cancel

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.

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

 


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

C:\user_tests\HOST\AMAGENT\run>powershell -NonInteractive -ExecutionPolicy bypass -NoLogo -file C:\user_tests\HOST\AMAGENT\exec\test.ps1 Hello World
Hello
World
No error file found. [C:\user_tests\HOST\AM9AGENT\run\doserr.205.00]end of C:\user_tests\HOST\AMAGENT\exec\BODY2.BAT status 0 
err is:'0'