Finish Actions for Configuration Manager OSD
Awesome post by Michael Murgolo over on the The Deployment Guys Blog.
MDT 2010 introduced a new feature called Finish Actions. This allowed you to set the variable FinishAction to either SHUTDOWN, RESTART (or REBOOT), or LOGOFF and the computer would be shutdown, restarted, or logged off after the task sequence (and subsequent cleanup) had completed. Unfortunately, this was only provided for Lite Touch deployments.
This same functionality was required in Configuration Manager OS deployments for a recent project of mine. So I created scripts that would allow the addition of a step to the task sequence that would consume the same variable and take the appropriate action. I wish I could claim credit for this idea, but I actually based this script off of scripts provided by Deployment Guy emeritus Richard Trusson . In this post, Richard created a script and HTA to implement a restart at the end of a BDD 2007 task sequence. To implement this required a two stage process. The task sequence step must call one script which then launches the second script that does the real work. The first script does not wait for the second script to complete before completing itself. That way the task sequence can continue and complete while the second script is still running.
The second script then waits for the task sequence to complete by watching for the task sequence process (TSManager.exe) to exit before doing its assigned task. For my implementation the first script, ZTI-SpawnProcess.wsf, will launch the command specified using the /cmd switch. The script to actually execute shutdown, restart, or logoff the is OSDFinishAction.vbs. This script takes two arguments, /FinishAction for specifying the action name and the optional /FinishActionDelay for specifying how many seconds to wait after TSManager.exe exits before executing the finish action.