When using the custom interpreter, the Automation Engine is not recognizing the proper return code from Powershell
For Powershell error trapping, use this Powershell syntax between :BEGIN_EXT_INT POWERSHELL and :END_EXT_INT POWERSHELL to force it to quit and send RC=1 back to Automic immediately;
$RC = $?
switch ($RC)
{
True { $EXIT_CODE = 0 }
False { $EXIT_CODE = 1 ; echo "Aborting script!" ; exit $EXIT_CODE }
default { $EXIT_CODE = 1 ; echo "Aborting Script!" ; exit $EXIT_CODE }
}
After :END_EXT_INT POWERSHELL add the following lines also:
@set retcode=%errorlevel%
@if NOT %ERRORLEVEL% == 0 goto :retcode