Capturing task sequence log files during OSD deployment.

This idea grew out of the need to troubleshoot certain task sequence errors.  Usually when your task sequence throws an error, the code will be displayed for an X amount of time after which the machine reboots.  Retrieving the SMSTS.LOG file is somewhat cumbersome, as the exact location of the file varies depending on which phase of the OSD the machine is in:

WinPE, Before HD Format x:\windows\temp\smstslog\smsts.log
WinPE, After HD Format x:\smstslog\smsts.log
Windows, No SCCM Client Installed c:\_SMSTaskSequence\Logs\Smstslog\smsts.log
Windows x86, SCCM Client Installed c:\windows\system32\ccm\logs\Smstslog\smsts.log
Windows x64, SCCM Client Installed c:\windows\sysWOW64\ccm\logs\Smstslog\smsts.log
Task Sequence Completed x86 c:\windows\system32\ccm\logs\smsts.log
Task Sequence Completed x64 c:\windows\sysWOW64\ccm\logs\smsts.log

An easier way to gather these logs is to take advantage of a Task Sequence Variable within the OSD deployment.  Whenever the task sequence finishes either successfully or not, the TS variable “_SMSTSLastActionSucceeded” returns a true or false value.  We can then leverage this variable to create a step in the task sequence to run only if the return value is false and then further run some steps to map a network drive and copy the logs over.  I was lucky to find an old post by Steve Rachui, a Microsoft Premier Field Engineer which helped saved me time brainstorming a solution.  However, my implementation makes use of the %OSDComputerName% variable and displays a custom error message in order to prevent WinPE from rebooting after clearing the countdown.

Below are the steps I took:

  1. Created a network share and allowed “Everyone” full access permission.  You can restrict this share to a specified AD account if you wish but you will then need to specify the account in the steps below.  I named my network share “TSLogCapture”.
  2. In the root of your task sequence, create a new group named “Task Sequence” and move all the steps as a subfolder to this new group.  In the Options tab, make sure the “Continue on error” box is checked.  The idea is to have all the steps grouped and if there is an error, pass control to the next group which will copy the logs to a share.10-31-2013 3-25-10 PM
  3. Also in the root of your task sequence, create another group named “Log Capture”.  In the Options tab add a condition to run when the task sequence variable “_SMSTSLastActionSucceeded” equals “False”.11-1-2013 8-25-52 PM
  4. We will need to add the above displayed steps to the “Log Capture” folder.  To add the first step, go to Add, General, Connect to Network Folder.11-1-2013 8-31-56 PM 

    In the Properties tab, you will need to specify a Path, Drive Letter and Account to connect and map the network share.  If you restricted the network share to a specific AD account, input that account here.  Also, please note I chose the “Z:” drive letter, therefore, all my command line entries reflect this drive letter.  If you choose a different drive letter, please update any subsequent command lines with this new drive letter.11-1-2013 8-35-04 PM

  5. Now we will need to add “Run Command Line” steps to the “Log Capture” folder.  To add this step, go to Add, General, Run Command Line.  This step will remove any pre-existing folders for that machine name you are currently using from the network share.  Its purpose is to prevent duplicate log files.11-1-2013 8-43-32 PM 

    In the Properties tab, type the following:11-1-2013 8-45-53 PM

    cmd.exe /c rd /s /q z:\%OSDComputerName%
  6. Add another “Run Command Line” step.  This step will create a folder named after the computer name in the TS variable %OSDComputerName% (a friendly name of your choosing).  You can also use %_SMSTSMachineName% which will name the folder after the random “MiniNT-12345” name if the error occurs in WinPE or after the actual AD computer name if the error happens in Windows.11-1-2013 9-00-26 PM
    cmd.exe /c md z:\%OSDComputerName%
  7. Add another “Run Command Line” step.  This step will copy the log files from the path contained within the %_SMSTSLogPath% variable to machine named folder in the network share.11-1-2013 9-03-58 PM
    cmd.exe /c copy %_SMSTSLogPath%\*.* z:\%OSDComputerName%


This last step is entirely optional.  I use it to display a custom error message using VBScript in order to prevent the error countdown from starting and rebooting the machine.  To add this step, you will need to create a Package out of one file, ErrorPrompt.vbs.  To create this file, open Notepad.exe and copy/ paste the following and update the path to your network share:

WScript.Echo "There was an error in the task sequence." & VbCrLf & VbCrLf & "Please review the log files stored at:  [Your Network Share Path Here]"

Next, save the VBScript file in a folder in your SCCM package repository and create a package using the SCCM Administration Console:

11-1-2013 9-24-09 PM

11-1-2013 9-27-54 PM

11-1-2013 9-34-38 PM

Click on “Next” all the way until the package is created.  Once complete, you will need to distribute it to your distribution points or groups.

11-1-2013 9-38-28 PM

11-1-2013 9-39-38 PM

10-31-2013 4-11-36 PM

10-31-2013 4-12-13 PM

Once again, click “Next” until you finish distributing the package.  You will need to watch the “Content Status” pane in the package information section to verify that the package was distributed successfully.

10-31-2013 4-12-56 PM 10-31-2013 4-13-49 PM

Now that you have created your package and have it distributed to your distribution points.  You may proceed creating that last “Run Command Line” step in your task sequence.  In the Properties tab, insert the following command line and don’t forget to specify the package we created:

11-1-2013 9-08-06 PM

cmd.exe /c wscript.exe errorprompt.vbs

Phew!  We are finally done!  Give yourself a good pat on the back because from now on, whenever your task sequence encounters an error, you will see the following:

11-1-2013 10-01-52 PM

11 thoughts on “Capturing task sequence log files during OSD deployment.

  1. Pingback: SCCM 2012 OSD integrated with HTA including offline backup – Part 1 | SCCM diet

  2. Pingback: SCCM 2012 OSD integrated with HTA including offline backup – Part 2 | SCCM diet

  3. Pingback: SCCM 2012 OSD integrated with HTA including offline backup – Part 3 | SCCM diet

  4. Pingback: SCCM 2012 OSD integrated with HTA including offline backup – Part 4 | SCCM diet

  5. Pingback: SCCM 2012 OSD integrated with HTA including offline backup – Part 7 | SCCM diet

  6. sebus

    It still needs to have a bit of logic build in (ie if exists), otherwise it will fail ITSELF if there is NO folder in “remove any pre-existing folders step”. Or use Continue on Error

    1. rcheing Post author

      Good call, however, as far as I can remember, no logic was needed for this step. While testing, the command prompt ran whether or not the folder pre-existed. I believe the logic is needed if say, in the next version of windows they omit the “rd” command and the command prompt calls to run this executable and it cannot be found.

    2. Ten4

      I´ve changed the command line in the Remove Folder step as follows:
      cmd.exe /c if exist z:\%OSDComputerName% rd /s /q z:\%OSDComputerName%

      Now it´s working!

  7. Pingback: Windows 10 Deployment | Monitor SCCM Task Sequence Progress

  8. Pingback: SCCMLIVE

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s