WPNinjas HeaderWPNinjas Header

Run a command after a task sequence has completed

​With Service Pack 1 for SCCM 2012, Microsoft introduced a few new task sequence variables. The one in the spotlight for this post is: SMSTSPostAction.

The SMSTSPostAction variable can be defined anywhere in the task sequence with a “Set Task Sequence Variable” step. Its value can be any command you wish, like:

  • Shut down the computer
    Command: shutdown /s /t 0shutdown
  • Run a PowerShell script (the script needs to be copied to the computer during the task sequence)
    Command: powershell -File “%TEMP%\Do-SomeStuff.ps1” -ExecutionPolicy ByPassps

This command is executed right after the task sequence was successfully completed. In the smsts.log the second last entry shows your post action command:

​Log Text Component​
​…
​Successfully removed C:\WINDOWS\system32\OSDSETUPHOOK.EXE ​OSDSetupHook
Successfully removed C:\WINDOWS\system32\_SMSOSDSetup​ ​OSDSetupHook
​End program: [your command] ​OSDSetupHook
Successfully finalized logs to SMS client log directory from C:\WINDOWS\CCM\Logs​ ​OSDSetupHook

 

Follow me

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.