search cancel

Powershell process not cancelled when job is canceled


Article ID: 211625


Updated On:


CA Automic Workload Automation - Automation Engine


When running a Windows job that runs a powershell - .ps1 - script like the following:

call C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Powershell.exe -executionpolicy remotesigned -File C:\scripts\sleep30.ps1

and cancelling before the script is finished, either using MRT or by manually cancelling the object, the powershell process does not end


Release : 12.3

Component :


This is caused because by default sub processes of a job object are not "bundled" with the job object.


The powershell process cancelling as well can be accomplished by setting the "Use Windows OS Job Object" on the Windows tab of the job to "Yes".  This will group together all child processes for the job (in this case including the .ps1) and when the cancel goes through due to MRT or manual cancellation of the job, it will cancel all sub-processes.  

Additional Information

Please see the "Use Windows OS Job Object" section of the following documentation: for more information.