Unable to run a job which runs powershell script
search cancel

Unable to run a job which runs powershell script


Article ID: 6049


Updated On:


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


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




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. 


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

For example...

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