I'm trying to use psadt through SCCM to run Dell's dcu-cli and its working great except for handling the exit codes. An exit code of 1 means it needs a reboot but PSADT is returning that as a failure. I've tried adding "1" using the -SuccessExitCodes parameter, the -RebootExitCodes parameter and even adding "1" to AppRebootExitCodes variable in the variable declaration section. No matter what I do 1 returns as a failure. I dont want to ignore the exit code because I'd like SCCM to reboot the computer. What am I missing
As far as I understand, I've only skimmed the source code for PSADT and am no expert in C#, the -RebootExitCodes really only impacts the logic that determines whether or not the Session's DeploymentStatus is returned as RestartRequired. This will impact balloon tips when showing installation progress dialogs and an entry being added to the log file seen here and here.
Additionally the -RebootExitCodes parameter allows you to have ExitCodes that are non-standard and give them a sort-of hall-pass to not get flagged as an error, but rather as a warning.
Example: Without the -RebootExitCodes
PS C:\WINDOWS\system32> $returnedPoo = Start-ADTProcess -FilePath cmd.exe -ArgumentList "somekindoffunction /? poo" -PassThru -CreateNoWindow -ErrorAction SilentlyContinue
Example: With the
-RebootExitCodes
PS C:\WINDOWS\system32> $returnedPoo = Start-ADTProcess -FilePath cmd.exe -ArgumentList "somekindoffunction /? poo" -PassThru -CreateNoWindow -ErrorAction SilentlyContinue -RebootExitCodes @(1)
Unfortunately though, they don't magically become something SCCM knows what to do with. So it's up to you to ensure that the ExitCode being passed back SCCM gives you the desired behavior. You can use custom return codes in any SCCM Application deployment and associate it with a Hard Restart or Soft Restart.
If you want to stick to built-in stuff, SCCM likes 3010 so we can work with that.
You could add whatever ExitCodes you are interested in considering as the ones that should trigger this reboot. In your case let's say we only add 1. You can add this ExitCode to the top in your $adtSession object if you don't want to specify it every time you call a process.
$adtSession = @{
# App variables.
AppVendor = 'VideoLAN'
AppName = 'VLC media player'
AppVersion = '3.0.21'
AppArch = 'x64'
AppLang = 'EN'
AppRevision = '01'
AppSuccessExitCodes = @(0)
AppRebootExitCodes = @(1641, 3010, 1) #<--- RIGHT HERE ! ! !
AppProcessesToClose = @(@{ Name = 'vlc'; Description = 'VLC media player' })
AppScriptVersion = '1.0.0'
AppScriptDate = '2025-07-29'
AppScriptAuthor = 'PSAppDeployToolkit'
RequireAdmin = $true
InstallName = ''
InstallTitle = ''
DeployAppScriptFriendlyName = $MyInvocation.MyCommand.Name
DeployAppScriptParameters = $PSBoundParameters
DeployAppScriptVersion = '4.1.7'
}
Or you can add in in-line when you call a process.
Start-ADTProcess -FilePath "$($adtSession.DirFiles)\dcu-cli.exe" -ArgumentList "YOUR ARGS HERE" -RebootExitCodes @(1641, 3010, 1)
I don't think you want to deal with all the error handling here so we'll try to use as much native stuff from the Toolkit as possible. If you plan on executing anything other than your CLI application your preferred method might vary. Since you are only talking about it's error codes (dcu-cli.exe), I'll assume you won't have any other processes that might affect the final exit code of the deployment. In this case you can just capture the ExitCode that the Start-ADTProcess functions spits out using this sort of function call:
[PSObject]$dcuResult = Start-ADTProcess -FilePath "$($adtSession.DirFiles)\dcu-cli.exe" -ArgumentList "YOUR ARGS HERE" -RebootExitCodes @(1641, 3010, 1) -PassThru -ErrorAction SilentlyContinue
Essentially you can capture the ExitCode property returned by using the -PassThru switch and stick it in a variable. Then you would check the ExitCode from $dcuResult.ExitCode and if it is 1 or whatever else you want to test for (I don't know what other codes dcu-cli.exe can return) that determines the ExitCode you will pass to close out the session. In your case you would force the ExitCode to be 3010 for SCCM when the dcu-cli.exe returns 1. Every other case we can just pass the ExitCode directly to close out so that you can see the other codes in the monitoring section of your deployment in SCCM.
You could do something like this:
$dcuExitCode = $dcuResult.ExitCode
# If DCU reports "1" -> treat as SCCM reboot required = 3010
if ($exitCode -eq 1) {
Close-ADTSession -ExitCode 3010
}
else {
# Pass through all other exit codes exactly as returned
Close-ADTSession -ExitCode $exitCode
}
Alternatively, if you had multiple processes running and you only wanted to react based on the last code in the $adtSession, you could leverage what is highlighted in the Example 2 of the Get-ADTSession reference docs.
Basically call Get-ADTSession right before closing out and then use the GetExitCode method. This block would appear right before the final catch {...}.
# Invoke the deployment and close out the session.
& "$($adtSession.DeploymentType)-ADTDeployment"
$adtSession = Get-ADTSession #<--- RIGHT HERE ! ! !
Close-ADTSession
$finalExitCode = $adtSession.GetExitCode()
You could then react based on this final exit code similarly to the other example above minus the Close-ADTSession bit, since it's already closed. In this case you'd sub-in a standard Exit.
Hope that helps,
Kindly,
Nik
P.S. Great username ![]()
@cantsleep is on the money; you're supposed to define your success/reboot codes in the $adtSession hashtable, which is why we've pre-populated them with some sane defaults so it's a visible queue that you can supply your own values.


