I'm attempting to retrieve an exit code from a PowerShell function and then exit with that code from an Automic JOB. I've confirmed that the function does exit with the appropriate exit code, it's just not getting back out to the JOB. Here's an example of the 'Process' tab on the JOB.
:BEGIN_EXT_INT POWERSHELL
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Confirm:$false -Force
Import-Module -Name "\\networkShare\customModule.psm1"
$VerbosePreference = "Continue"
Custom-Function -Verbose
:REGISTER_VARIABLE EXIT_CODE#, $LastExitCode
:END_EXT_INT POWERSHELL
:Exit &EXIT_CODE#
When I run this, I receive an error:
Syntax error in object 'JOBS...' line '00014'. 'U01001308 Variable 'EXIT_CODE#' has not yet been defined.