Exit-Script -ExitCode 3010 does not work

Hi,

Did something change with this function?
If I want my script to explicitly exit with Exit-Code 3010 (soft reboot) so that SCCM shows that reboot is required, it doesn’t work.

It doesn’t work if I set $mainExitCode = 3010
Or by running: Exit-Script -ExitCode 3010

Also no change if I set the variable $msiRebootDetected = $true

I’ve tried this with PSADT 3.8.0 and with 3.7.0

I’ve added my own log entries to check what the exit code should be.
In the log I can clearly see that “$mainExitCode” is “3010” because I’ve set it.
But script still exists with zero (0)

[Post-Uninstallation] :: Main Exit Code should be 3010. Main Exit Code is: 3010 (<- from variable $mainExitCode)
[Post-Uninstallation] :: SymantecEndpointProtectionUninstall Uninstallation completed with exit code [0].

What is going on here?

The toolkit will always return exit code 0 UNLESS you add the -AllowRebootPassThru switch to the command line (from the PSADT Administrator Guide):

Deploy-Application.exe -AllowRebootPassThru

Deploy an application for installation, supressing the PowerShell console window and allowing reboot codes to be returned to the parent process.

Another way to achieve the same goal is to edit the return codes for the application in the Configuration Manager console. Open the Application properties and set Return Code 0 to code type Soft Reboot. When your application returns exit code 0 SCCM will then initiate a soft reboot, the same as if you passed exit code 3010.

1 Like

Exit-Script -ExitCode ‘255’ always works ok for me on both 3.7.0 and 3.8.0

If you’re trying to restart after the install happens I’d use the “configuration manager will restart” function of the application in the console. Or add a restart at the end of the psadtk package.

-AllowRebootPassthru; also make sure your deployment in configman is has post install behavior set to be dependent on the exit code.

create a batch file as exit_code.bat, write line exit /b 3010. and call this batch from your script at desired end, script will always end with exit code 3010, if you do not want to make changes in sccm.

No need for batch files, PSADT can return any exit code you want but the toolkit (without -AllowRebootPassThru) silences exit code 3010. It is a feature so you handle reboot the way you need/want to.

1 Like