ALERT: Some images may not load properly within the Knowledge Base Article. If you see a broken image, please right-click and select 'Open image in a new tab'. We apologize for this inconvenience.

AE - Embedded AE scripting in PowerShell is always executed


Article ID: 103495


Updated On:


CA Automic Workload Automation - Automation Engine


We want to use Automic script functions inside a PowerShell script.
However, it does not work as expected.
The Automic function is inside a PowerShell function so, it should only be executed if the PowerShell function is called.
This is not the case, the Automic function is always executed. Do you know if we can prevent this behavior?
  • An example script
:BEGIN_EXT_INT powershell

:SET &errorOccured# = "False"
write-host errorOccured value: &errorOccured#

! Function to stop script and write result to variable if an error occured
Function errorHandling ($str) {
  write-host ($str)
  write-host "ERROR occured: errorOccured variable set to True.`r`n"
: SET &errorOccured# = "True"

write-host errorOccured value: &errorOccured#

: END_EXT_INT powershell
  • The job report will look something like this
c:\>powershell -ExecutionPolicy Unrestricted -File C:\Users\ntd\Downloads\windowsagent\Resources\0001\0001041139\0001041139_0001.ps1 
errorOccured value: False
errorOccured value: True


Component: ARAINF


I believe that the way you mix Automic script function with PS is not how it work.
You better change your PS function and somehow save it to a PS variable.
Then you can use our :REGISTER_VARIABLE to store the PS value to Automic variable.

Additional Information

Please check the follow links for more detail about External interpreter:


How to use an external interpreter:


Practical examples: