Sending an exit code to SCCM

Is it possible to send an exit code to SCCM. I am uninstalling and then reinstalling a newer version of Imprivata. If no one is logged in, I want it to send an Exit code of 3010 (reboot required) back to SCCM. I have it using the start-installationrestartprompt when someone is logged in and it brings up the restart prompt and works flawlessly.

It is returning an exit code of 0 when I need it to return an exit code of 3010 if know one is logged in.

Execute-MSI -Path “$dirFiles\x64\ImprivataAgent_x64.msi” -TRANSFORM “$dirFiles\x64\ImprivataAgent_x64.mst” -Passthru

The command line I am using in SCCM is:

“Deploy-Application.exe” -AllowRebootPassThru

Because the Exit Code is 0, the Reboot is not happening when I deploy through SCCM. How would I tell the script to send back error code 3010?

Thanks,

Donna

about 10 from the bottom Exit-Script -ExitCode 3010

This is because you are using the -passthru switch, this tells the script to ignore the result of the execution, you could capture it in an object for future use with something like:

[PSObject]$msiResult = Execute-MSI -Path “$dirFiles\x64\ImprivataAgent_x64.msi” -TRANSFORM “$dirFiles\x64\ImprivataAgent_x64.mst” -Passthru

Then you then test the previously captured exit code using the same object
If ($msiResult.ExitCode -eq 3010){Exit-Script -ExitCode 3010}

There is no reason to use a passthru switch parameter. Execute-MSI will return whatever it returns (3010 if it flags a reboot is required) and then that will be returned when the script exits by default. However, if you want the computer to always reboot after the app is installed, then control that in the deployment type in SCCM and tell it to always reboot, instead of relying on the MSI’s exit code.