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.
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:
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.
This is really simple, If you want to reboot machine after application is done installing, after everything is done from msi or exe, you can just run one simple batch file with a single line.
EXIT /B 3010.
this will change return error on application install and this will show return code as 3010 always once application is done installing, now all you need to do is control this behavior via sccm, so you can refer articles and settings of psappdeploytoolkit doc file and check how to make sccm restart after app install.
I have recently done this in my env and it worked fine with sep install.
When it comes to reboot, add -AllowRebootPassThru as a parameter for Deploy-Application.exe in SCCM otherwise the toolkit will silence successful reboot exit codes and return 0. No need for additional batch files etc.
I should add that Execute functions have to return 3010 otherwise the toolkit has nothing to silence. If you want to make sure it is a 3010 exit code, put $mainExitCode = 3010 after the last Execute function.