Capture Task Sequence Logs during OSD

SCCM has this really annoying habit of not keeping TS logs accessible after completing an OSD task sequence. Unfortunately, this also applies when the TS fails. To combat this problem, I implemented the following solution from Steve Rachui, which moves the TS logs to a network share for proper archiving and ease of access.

To do this, I added a new group to my main task sequence called Log Upload. I selected the “Log Upload” group and went to the Options tab, and added a Task Sequence Variable condition wherein we check whether _SMSTSLastActionSucceeded equals false. If so, it executes the group. I added four steps to this group:

  1. Connect to SMSTSLogUploads – This is a Connect to Network Folder step, which connects to a folder on our SAN using our SCCM service account, mapping it to Z:\.
  2. Erase pre-existing folder for machine – This is a Run Command Line step, which executes the following command line step to delete any folder that had already been created for the machine being imaged: cmd.exe /c rd /s /q z:\%_smstsmachinename%%
  3. Create log folder for current machine – This is another Run Command Line step, which creates a folder on the share for the computer currently running the TS: cmd.exe /c md z:\%_smstsmachinename%%
  4. Copy logs to folder – Our last step, also a Run Command Line step, this actually handles the copying of the log files to the newly-created folder: cmd.exe /c copy %_smstslogpath%\*.* z:\%_smstsmachinename%

It’s important to set this whole group to “Continue on Error,” otherwise it will fail if any of the individual steps fail, and report your entire TS execution as a failure. In my first test run, I hadn’t set this option, and the TS failed when it wasn’t able to delete the not-yet-existing folder on the share in step 2. Note that you’ll also want the preceding steps to continue on error as well, otherwise the TS won’t even get to this part on failure.

Next time, I’ll talk about using a script to send an alert email when a task sequence fails!

Leave a Reply

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

Please do some math to prove you\'re a human: * Time limit is exhausted. Please reload the CAPTCHA.