05 September 2019

Custom Task Sequence Variables and the SMSTSRebootRequested

While writing a new PowerShell script for SCCM, I needed to be able to keep track of how many times a system had rebooted when using the SMSTSRebootRequested. The apparent solution, at least what I initially thought, was to create a TS variable and increment it upon each reboot.

It ended up never ceasing the reboot process, and the task reran indefinitely. I began debugging the variables by using message boxes to display the value of the associated TS variable. I found the newly created TS variable was disappearing every time the system rebooted. I proceeded to comment out the SMSTSRebootRequested line and made a copy of the task so that it would not rerun itself, but would continue to run the very next task, which was the exact same thing. Sure enough, upon executing the second task, the values did increment and had not been cleared out.

The solution to this was to write the values assigned to the custom task sequence variable to a text file on the drive that would be changed each time the task sequence reran. At the last execution, the file is deleted. 
Reactions:

0 comments:

Post a Comment