V4.0.6 - Exit Codes

I have a deployment I'm working on using 4.0.6 and for some reason the exit codes have stopped working. It did work previously so I'm not sure what happened. I haven't updated the core components of the deployment; just made minor changes to the script I'm developing within PSADT. I haven't updated the package but it always exits with code [0] but I'm calling Clost-ADTSession -ExitCode 3010 and I have even set the variable AppSuccessExitCodes = @(3010) to 3010 as well.

Here's the exiting part of my script:

    Write-ADTLogEntry -Message "Initializing closure of ADT session with exit code [3010]." -Severity 0 -Source 'GenShare Finalization'
    Close-ADTSession -ExitCode 3010
    Write-ADTLogEntry -Message "Passed Close-ADTSession request, moving to default closure process." -Severity 0 -Source 'GenShare Finalization'

I don't get the log entry after calling Close-ADTSession so I know it's closing there. Any ideas why the exit code wouldn't be getting passed through and it would be forcibly putting in code 0? I'm working on changing this to v4.1.0 but there are some hangups there that I plan on making another post regarding but for now I need to get this working properly in v4.0.6. The goal is for this to return 3010 so that the device will reboot at the end of an AutoPilot deployment from Intune. As long as the code 3010 gets passed along everything works great. I know I can change Intune to reboot on exit code 0 but I would like to understand why the code I'm specifying is not being passed through.

In 4.0.x and older, you need to specify -AllowRebootPassThru for this to work. We changed this in 4.1 so that the -AllowRebootPassThru pathway is the default mode of operation.

3 Likes

Ohhhh thats right! I dont think I included that switch when I changed my deployment back to 4.0.6! I'll give that a check first thing in the morning!

3 Likes

So I've been working on this and have seen some odd behavior. When I now include the -AllowRebootPassThru switch, I do see in the logs the PSADT exiting with exit code 3010, but my Intune AppWorkload log file is reporting exit code 1 and showing that it failed.

If I remove the -AllowRebootPassThru switch PSADT exits with code 0 and the Intune logs show exit code 0.

Any idea where I could look for why exit code 1 is being reported by the Intune logs when my deployment shows it sent 3010? This worked before so I'm not sure if I accidentally did something to the package or what happened. Really hoping I'm just being dumb and missed something. I'm still doing some testing so will report back if I find anything out myself, going to try passing different error codes than 3010 and see what it reports back.

An exit code of 1 from PowerShell typically points to a syntax error of some kind, or some other kind of unhandled error.

On your test device, perhaps configure transcription via local GPO or via a config profile so you can get some visibility into what's going wrong within PowerShell.

On another note though, I'd probably move up from 4.0.6 to 4.1.3 as it's got all that ServiceUI-less goodness within it. It'll also exit with the reboot codes by default.

1 Like