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?
: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