Trap batchmode return code in PowerShell

We are moving a system from Natural for UNIX to Natural for Windows. We need to convert .bsh scripts to PowerShell. Many of the batch programs use TERMINATE to return a non-zero return code. In the BASH scripts, the return is available from the $? variable. In DOS the ERRORLEVEL variable is equivalent, and works fine. The PowerShell equivalent is supposed to be LASTEXITCODE. However this variable always contains 1 after batchmode invocation of NATURAL, regardless of the TERMINATE value returned by the Natural program. PowerShell also provides a ? variable, but it is a boolean (True/False).
Is there a way to get the actual TERMINATE value (the return code) within a PowerShell script after BATCHMODE execution of a NATURAL program?