I am installing a rather complex piece of software using a task sequence in SCCM 1607 (aka SCCM 2016). Within the task sequence, I have a try/catch block so I can restore the computer to a working state if the TS fails.
Like so:
The problem here is that when there is an actual failure within the task sequence, the error handling routine does its job and the task sequence exits gracefully. I'm capturing my own logs within the sequence to reflect the error, but as far as SCCM is concerned, the installation was a success. The user does not receive any kind of notification and the application shows in Software Center as installed even though though it isn't. I have to look at my own logs to get any kind of reporting on the errors, and SCCM will never retry the installation on its own.
How can I force the task sequence to fail as the last step in my error handling block? I want the user to see an error and call the help desk. I also want to be able to see the failure in the SCCM console, and I want to have the TS retry on its own (the old version fails to uninstall if it's in use and almost all of the failures I've seen in testing are because the user logged in and launched it before the TS had a chance to remove it).