Using Task Sequence Variables to make life a bit easier in ConfigMgr 2007

Sometimes you think you’ve got it all, so you start looking for things to make it better and easier. Well…, to be honest I’m not even close to having it all, but I am looking to make things better and easier. This is why I started looking more on using Task Sequence Variables, because they can make life a whole lot easier. In this post I will use a Task Sequence Variable to prevent the need of building two separate Task Sequences.

Let’s start with telling the scenario. I have a Task Sequence that I use for a computer-refresh by using hard-links (take a look at thisprevious post). Now I want to use the same Task Sequence to perform a clean install.TSVariable Of course it’s easy to just say, like in the default Install Task Sequence, that the step of Capture User Files and Settings only has to run when _SMSTSInWinPE equals TRUE. The only problem for me with this is that you have to set the step Restore User Files and Settings to Continue on error. I only want an error when there is really something wrong, not just because the Task Sequence can’t locate a store that doesn’t exist…

This is where the fun starts and where it makes sense to create a Task Sequence Variable. In this scenario the computer-refresh can only be started in FullOS, so when the Task Sequence gets started from WinPE it is not needed/ possible to perform a computer-refresh. This is why the first step in my Task Sequence (red arrow) only creates a Variable when _SMSTSInWinPE equals TRUE. I create here a Variable called CaptureRestoreUserFilesSettings with the value NO. Now I can use this Variable in the rest of the Task Sequence to decide whether or not some steps have to run. The steps Capture User Files and Settings and Restore User Files and Settings (first and third red rectangle) will only run when my Variable CaptureRestoreUserFilesSettings not equals NO. So that’s always except for when the Task Sequence started from WinPE. It’s not necessary to give the Variable a different value when the Task Sequence is running in FullOS, because when the Variable doesn’t exists it can’t equal NO either (nice and cryptic).  The step Partition Disk 0 (second red rectangle) will only run when CaptureRestoreUserFilesSettings equals NO. So that’s only when the Task Sequence is started from WinPE.

This same construction can of course be used in many different ways and scenario’s, all I tried to do is showing an example. To conclude this story, I don’t say that you have to use Task Sequence Variables, but I do say that it can make your life a lot easier.

ConfigMgr 2007, USMT 4.0 and using Hard-Links

One of the coolest new functions of USMT 4.0 is the new hard-link migration store (only for computer-refresh scenarios). These migration stores are stored locally on the computer that is being refreshed and can migrate user accounts, files and settings. This way it will save time and space during a computer-refresh (and you do not need a State Migration Point!). HardLinkTS

When you create a default Task Sequence it will create the steps Request User State Storage and Release User State Storage. These steps are needed to interact with the State Migration Point (SMP) to get available space and to tell that the action completed successfully. So these steps are not needed anymore when you are using hard-links! This is why these steps are grayed out in the picture. Instead we need to define three variables:

  1. OSDStateStorePath: Defines the path to the user state store. This path must be on a local drive. As path I use the value:    %_SMSTSUserStatePath%. This Task Sequence Variable must be set before the step: Capture User Files and Settings.
  2. OSDMigrateAdditionalCaptureOptions: Specifies the extra options needed to perform a hard-link migration capture and must include /nocompress /hardlink. This Task Sequence Variable must be set before the step: Capture User Files and Settings.
  3. OSDMigrateAdditionalRestoreOptions: Specifies the extra options needed to perform a hard-link migration restore and must include /nocompress /hardlink. This Task Sequence Variable must be set before the step: Restore User Files and Settings.

The picture with this post shows a plain and simple example about how a Task Sequence could look with hard-links enabled. In the red rectangles I created my Task Sequence Variables and the still needed steps of Capture User Files and Settings and Restore User Files and Settings. Because I still use these default ConfigMgr 2007 steps it is not possible to run the capture in WinPE.

More information about USMT 4.0:
More information about USMT 4.0 Hard-Link Migration:
More information about How to use Hard-Links for User State Migration:

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.

How to create a Capture Only Task Sequence with ConfigMgr 2007

Some things are a lot easier then you might think. One of these things is creating a Capture Only Task Sequence. As you all know there is the option within ConfigMgr 2007 to create a Build and Capture Task Sequence, well creating a Capture Only Task Sequence is nothing more then taking the Capture part of the default Build and Capture Task Sequence. So I use in my Capture Only Task Sequence the following steps:CaptOnlyTS

  • Join Workgroup (this step is only necessary when the Reference Machine is joined to a domain)
  • Prepare ConfigMgr Client
  • Prepare OS
  • Capture the Reference Machine

The first steps all need to run in Full OS, which means that you can’t start this Task Sequence by booting in WinPE. I just create an Advertisement without a Mandatory Assignment. This makes the box Allow users to run the program independently of assignments ticked, which makes sure that the Advertisement will show in the Run Advertised Programs on the client. You need to make sure that when you want to use this that the Reference Machine is within the Boundaries of your ConfigMgr 2007 environment. Another option in some, maybe most, cases is to create a Capture CD (see Technet for a How To:

Keep in mind that if you want to do this with Windows XP that you need a step Install Deployment Tools to copy the Sysprep Package to the machine. I put that step most of the time at the end of my Build Task Sequence.

Installing Software Updates via a Task Sequence in ConfigMgr 2007

I noticed that when your Site is running in Native Mode you can run into problems with installing Software Updates via a Task Sequence. The first time that your are installing your computer with your Task Sequence there are no problems, but every time after that the Task Sequence will finish successful but doesn’t install any Software Updates. It looks like that it will use existing scan results of the client from the previous scan. So when there are already scan results of your client it will not rescan during your Task Sequence.

To work around this I use the following scripts (that I run before the step Install Software Updates in the Task Sequence):

  1. Initiate Software Updates Scan:
    actionNameToRun = “Software Updates Assignments Evaluation Cycle”

    Dim oCPAppletMgr
    Set oCPAppletMgr = CreateObject(“CPApplet.CPAppletMgr”)

    Dim oClientActions
    Set oClientActions = oCPAppletMgr.GetClientActions()

    ‘Loop through the available client actions. Run the matching client action when it is found.
    Dim oClientAction
    For Each oClientAction In oClientActions
       If oClientAction.Name = actionNameToRun Then
       End If

  2. Refresh Compliance State:
    dim newCCMUpdatesStore
    set newCCMUpdatesStore = CreateObject (“Microsoft.CCM.UpdatesStore”)

    ‘Refresh the server compliance state by running the RefreshServerComplianceState method.

The first script Initiate Software Updates Scan is to let the client check if it needs new updates and the second script Refresh Compliance State is to let the client report back to the server that it needs updates.

Note: It can also happen when you are trying to avoid obsolete clients by starting the Task Sequence via Run Advertised Program.