Unable to run a job which runs powershell script

book

Article ID: 6049

calendar_today

Updated On:

Products

CA Workload Automation AE - Business Agents (AutoSys) CA Workload Automation AE - Scheduler (AutoSys) CA Workload Automation Agent

Issue/Introduction

When attempting to run a job on Windows agent that executes a PowerShell script, the job goes to RUNNING status and the script is not executed. The job stays in RUNNING status until it is issued a KILLJOB event. 

The job command is specified in the format...

command: c:\test\ps_script.ps1

Cause

The WA Agent on Windows executes commands through the Windows command-line interpreter (cmd.exe). When executing a PowerShell script from the Windows command-line interpreter, you must run it using the 'powershell -file <script_name>' command. Otherwise, the script is just opened in the default text editor associated with .ps1 files on the Windows machine. This is why the job will stay in the RUNNING status and not actually execute the script. When the job is launched, the script is opened into a text editor in the background on the Windows agent machine and does not actually execute. It also does not exit. 

Environment

Windows

Resolution

Modify the job's command attribute so that the script is executed through PowerShell.

For example...

command: powershell -file c\:\test\ps_script.ps1