Copy logs from a failed Task Sequence in ConfigMgr 2007

I like to do multiple things at a time… So I don’t like to wait on my Task Sequence, after I made a a few changes, to see if it doesn’t fail. This is why I searched for some sort of error catching in a Task Sequence. During this search I found this great article of Steve Raichu:

In this article he explains the following important steps that are needed for an automatic error catching:

  1. Use a top group in a Task Sequence that is set to Continue on error. The rest of your functioning Task Sequence has to be added under this group. In this way the Task Sequence will continue to the following group if a part of the Task Sequence has failed.
  2. Use a Error Catching group that is set to run when _SMSTSLastActionSucceeded equals FALSE. This group will only start when the top group has failed.

These steps are the most important. After these steps you can pick your own way in what to do during the Error Catching group. In my Error Catching group I use the following two steps:

  1. Connect to Network Folder: In this step I create a connection with a Network Share.
  2. Run Command Line: In this step I start a script which is located on the Network Share that I connected in the previous step. This script looks like this:

Set fso = CreateObject("Scripting.FileSystemObject")
Set env = CreateObject("Microsoft.SMS.TSEnvironment")

dim logPath
dim errorLogPath
dim machineName

logPath = env("_SMSTSLogPath")
machineName = env("_SMSTSMachineName")
errorLogPath = "Z:\LOGS\" & machineName

If fso.folderExists(errorLogPath) then
    fso.DeleteFolder errorLogPath, True
End If

fso.CopyFile logPath & "\" & "*.*", errorLogPath, True

This script copies the logs from the Task Sequence Log Path to a folder, on the network share, that has the name of the machine. If the folder already exists then it will be deleted first.

Leave a Comment

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