How to use Task Sequence Variables in a running Task Sequence by script in ConfigMgr 2007

Using Task Sequence variables in a running Task Sequence by script is actually really straight forward. Also for most of you this might be common knowledge, but I noticed this week that it doesn’t count for everyone, yet. So in this post I will show the two (only two!) steps it takes to get or set variables with your script.

The first step is to create an instance of Microsoft.SMS.TSEnvironment. As this is a COM automation object, you could use every language that can use those. I will use VBScript in this example. Creating the object can be done by the following line of code:

set env = CreateObject(“Microsoft.SMS.TSEnvironment”)

Now that we’ve got our object the second step is to get, or set Task Sequence variables. This can be done by either one of the following lines of code:

GET: machineName = env(“_SMSTSMachineName”)

SET: env(“YourCustomVariable”) = “Your Custom Value”

By setting the new variable you can use any variable(name) that you want. If the variable does not exist, it will be created. If the variable does exist, its value will be updated.

For more information: http://msdn.microsoft.com/en-us/library/cc145669.aspx

ConfigMgr 2007 and clearing a Computers’ Last PXE Advertisement by script

In a previous post I showed a script to remove a computer from a collection. This post will be an add-on to that previous post. As we are removing the computer from the collection anyway, we can as well perform a Clear Last PXE Advertisement –action. By doing this, it’s not necessary to perform a manual action the next time the computer needs to be re-imaged.

ClrLstPXEAdvAn easy way to do this is to run a script at the end of a Task Sequence that will clear the last PXE Advertisement. This makes sure that a computer can get re-imaged as soon it gets added to the correct collection. For this you can use the script from this post.

The usage of this script is cscript <ScriptName>.vbs /ComputerName:[ComputerName]. Keep in mind that it needs to be run with an account that has enough rights in ConfigMgr. See also this picture for an example.

Option Explicit

DIM objSWbemLocator, objSWbemServices, ProviderLocation, Location, Connection
DIM colResourceID, objResourceID, iResourceID, aResources, InParams
DIM sComputerName, sSiteServerName, objArguments

sSiteServerName = “<SiteServerName>”

‘====================================
‘ Check arguments
‘====================================
Set objArguments = Wscript.Arguments
If WScript.Arguments.Count = 1 Then
   sComputerName = objArguments.Named.Item(“ComputerName”)
Else
   Wscript.Echo “Usage: ClearPxeAdvertisement.vbs /ComputerName:[ComputerName]”
   Wscript.Quit
End If

‘====================================
‘ MAIN Script
‘====================================
Set Connection = ConnectToSMSProvider(sSiteServerName)
iResourceID = GetResourceID(Connection, sComputerName)

aResources = Array(1)
aResources(0) = iResourceID

Set InParams = Connection.Get(“SMS_Collection”).Methods_(“ClearLastNBSAdvForMachines”).InParameters.SpawnInstance_
InParams.ResourceIDs = aResources

Connection.ExecMethod “SMS_Collection”,”ClearLastNBSAdvForMachines”, InParams
WScript.Echo “Cleared PXE advertisement for resource: ” & iResourceID

‘====================================
‘ Function to RETURN a Connection to the SMS Provider
‘====================================
Function ConnectToSMSProvider(ServerName)
   Set objSWbemLocator = CreateObject(“WbemScripting.SWbemLocator”)
   Set objSWbemServices = objSWbemLocator.ConnectServer(ServerName, “root\sms”)
   Set ProviderLocation = objSWbemServices.InstancesOf(“SMS_ProviderLocation”)
   For Each Location In ProviderLocation
      If Location.ProviderForLocalSite = True Then
         Set objSWbemServices = objSWbemLocator.ConnectServer(Location.Machine, “root\sms\site_” + Location.SiteCode)
         Set ConnectToSMSProvider = objSWbemServices
      End If
   Next
End Function

‘====================================
‘ Function to RETURN a ResourceID by a ComputerName
‘====================================
Function GetResourceID(Connection, ComputerName)
   Set colResourceID = Connection.ExecQuery(“Select ResourceID from SMS_R_System where Name = ‘” & ComputerName & “‘”)
   For Each objResourceID in colResourceID
      GetResourceID = objResourceID.ResourceID
   Next
End Function

WScript.Quit(0)

There also exists an (basic) example on MSDN about How to Clear a PXE Advertisement for a Configuration Manager Resource, here: http://msdn.microsoft.com/en-us/library/cc143002.aspx

ConfigMgr 2007 and removing a Computer from a Collection by script

I have to admit that it’s just really easy/ handy to create scripts to make life a bit easier. This also counts for this scenario… A customer wants to prevent, at all costs, that a computer can’t get re-imaged “by accident”. It already happened a few times that somebody by accident did a Clear Last PXE Advertisement on a Computer, or even on a Collection.

An easy solution for this scenario is to run a script at the end of a Task Sequence that will remove the Computer directly from the Collection. This makes sure that a computer can’t get re-imaged, as it’s not a member of the collection anymore. For this you can use the script from this post.

RemCompfrCollThe usage of this script is cscript <ScriptName>.vbs /CollectionID:[CollectionID] /ComputerName:[ComputerName]. Keep in mind that it needs to be run with an account that has enough rights in ConfigMgr. See also this picture for an example.

Option Explicit

DIM objSWbemLocator, objSWbemServices, ProviderLocation, Location, sSiteServerName
DIM sComputerName, sCollectionID, objCollection, colRuleSet, Rule, objArguments

‘=============================
‘ Check arguments
‘=============================
Set objArguments = Wscript.Arguments
If WScript.Arguments.Count = 2 Then
   sCollectionID = objArguments.Named.Item(“CollectionID”)
   sComputername = objArguments.Named.Item(“ComputerName”)
Else
   Wscript.Echo “Usage: RemoveComputerFromCollection.vbs /CollectionID:[CollectionID] /ComputerName:[ComputerName]”
   Wscript.Quit(0)
End If

‘=============================
‘ MAIN Script
‘=============================
sSiteServerName=”<SiteServerName>”
ConnectToSMSProvider(sSiteServerName)

Set objCollection = objSWbemServices.Get(“SMS_Collection='” & sCollectionID & “‘”) 
colRuleSet = objCollection.CollectionRules
For Each Rule In colRuleSet
    If Rule.Path_.Class = “SMS_CollectionRuleDirect” Then 
        If LCase(Trim(Rule.RuleName)) = LCase(Trim(sComputerName)) Then 
            objCollection.DeleteMembershipRule Rule
            Wscript.Echo “Succesfully removed ” & sComputerName & ” from collection: ” & sCollectionID
        End If
    End If
Next

‘=============================
‘ Sub Routine to Connect to the SMS Provider
‘=============================
Sub ConnectToSMSProvider(SiteServerName)
   Set objSWbemLocator = CreateObject(“WbemScripting.SWbemLocator”)
   Set objSWbemServices = objSWbemLocator.ConnectServer(SiteServerName, “root\sms”)
   Set ProviderLocation = objSWbemServices.InstancesOf(“SMS_ProviderLocation”)
   For Each Location In ProviderLocation
      If Location.ProviderForLocalSite = True Then
         Set objSWbemServices = objSWbemLocator.ConnectServer(Location.Machine, “root\sms\site_” + Location.SiteCode)
      End If
   Next
End Sub

WScript.Quit(0)

ConfigMgr vNext: It just gets easier and easier.

Its about time that I write my first post about ConfigMgr vNext BETA and well I really have to say that it just gets easier and easier compared to ConfigMgr 2007. The only thing I have to get used to is that everything is in a different location.

Capture User Files and Setting Offline (WinPE) with Hard-Links

HardLinkOnOffvNextAs I have been busy a lot with capturing user files offline on my blog, lets start about how easy that becomes in ConfigMgr vNext. I still remember making BAT-files to run the ScanState –commands, in ConfigMgr vNext its just selecting the checkboxes Capture locally using links instead of copying files and Capture in off-line mode (WinPE only). After this the Capture User Files and Settings –step will run with the command C:\_SMSTaskSequence\Packages\P010000A\amd64\scanstate.exe C:\_SMSTaskSequence\UserState /o /localonly /efs:skip /all /v:5
/offlineWinDir:C:\WINDOWS /c /hardlink
/nocompress /l:X:\WINDOWS\TEMP\SMSTSLog\scanstate.log
/progress:X:\WINDOWS\TEMP\SMSTSLog\scanstateprogress.log
/i:C:\_SMSTaskSequence\Packages\P010000A\amd64\miguser.xml /i:C:\_SMSTaskSequence\Packages\P010000A\amd64\migapp.xml.

Even the variable OSDStateStorePath gets set to %_SMSTSUserStatePath% automatically by selecting Save user settings locally during the Create Task Seqeunce Wizard.

Schedule Updates on a Operating System Image

ImageProp Another cowl feature I ran into, with creating the Operating System Image for the Task Sequence, is the option to Schedule Updates for an already created Operating System Image. By doing this ConfigMgr will insert the selected updates into the Operating System Image. No more problems with installing Software Updates during the Build and Capture –proces, can it get easier then this?

After this it is also possible to see the which Software Updates exist in the Operating System Image (see picture). Now you will always be able to see how up-to-date your reference image is!

Of course there are lots and lots of more cowl feature, like the Software Center, the Online Software Catalog, the Automatic Grouping Rules for Software Updates, the Client Agent Settings, etc, etc, etc… But, at my defence, these are all to big to be covered in one post.

Capture User Files and Settings Offline (WinPE) or Online (FullOS) with ConfigMgr 2007

They always say never change a winning team, but sometimes its just cowl to see if its possible to be even better. I had the same with a previous post in which I already showed how to do a Hard-Link migration, when started from WinPE (and FullOS). The biggest part of that example is still the same, but some pieces changed to get a better result.

In this post I will go step-by-step (again) to mention the changes that I made to make it even better. At the end of both parts of this post I will shine a light on the changes that I made.

Part 1: Capture User Files and Settings

HardlinkOnOffTSFor creating a Task Sequence, that does an Online or Offline Capture, my way, a few variables and locations need to be created. After that a command line has to be run to do the actual Capture. Under here I will sum up the steps I take to do an Online and Offline Capture (also see the first red rectangle in the picture):

  • Set Started in WinPE – Set Task Sequence Variable
    This step sets the Task Sequence Variable TSStartedInWinPE to YES. This Task Sequence Variable only gets set when _SMSTSInWinPE is TRUE.
  • Set Architecture – Set Task Sequence Variable
    This step sets the Task Sequence Variable Architecture to amd64. This variable will be used for selecting the USMT 4.0 version for (in my case) 64-bit systems.
  • Set Windows Partition – Set Task Sequence Variable
    This step sets the Task Sequence Variable WindowsPartition to C:. This variable will be used for selecting the Windows partition.
  • Set State Store Location – Set Task Sequence Variable
    This step sets the Task Sequence Variable OSDStateStorePath to %WindowsPartition%\StateStore. This variable will be used for creating and selecting the User State Location.
  • Create State Store Location – Run Command Line
    This step creates the directory %WindowsPartition%\StateStore by running the Command line: cmd /c MKDIR %OSDStateStorePath%.
  • Cache USMT Files and Scripts – Run Command Line
    This step caches the USMT Files and Scripts from the USMT Package to the directory %OSDStateStorePath%\USMTFiles\ by running the Command line: xcopy * %OSDStateStorePath%\USMTFiles\ /herciy
  • Capture User Files and Settings – WinPE – Run Command Line
    This step does the actual Offline Capture of the User Files and Settings by running the Command line RunScanState_WinPE.BAT %OSDStateStorePath% %WindowsPartition% %Architecture% %_SMSTSLogPath% which has to start in the directory %OSDStateStorePath%\USMTFiles\. This step only runs when the machine is started from WinPE. This is done by checking if the Task Sequence Variable TSStartedInWinPE is set to YES.
  • Capture User Files and Settings – FullOS – Run Command Line
    This step does the actual Online Capture of the User Files and Settings by running the Command line RunScanState_FullOS.BAT %OSDStateStorePath% %WindowsPartition% %Architecture% %_SMSTSLogPath% which has to start in the directory %OSDStateStorePath%\USMTFiles\. This step only runs when the machine is started from FullOS. This is done by checking if the Task Sequence Variable TSStartedInWinPE is not set to YES. 

These are all the steps I need, to do an Online or Offline Capture with Hard-Links. Now let’s take a closer look at the batch-files which do the most of the work:

RunScanState_FullOS.BAT

REM ======================================================
REM ARGUMENT -1- OSDStateStorePath     = %1
REM ARGUMENT -2- WindowsPartition    = %2
REM ARGUMENT -3- Architecture        = %3
REM ARGUMENT -4- LogDirectory        = %4
REM ======================================================

SET USMT_WORKING_DIR=%1\USMTFiles\%3

REM ======================================================
REM RUN Scanstate
REM ======================================================

"%1\USMTFiles\%3\Scanstate.exe" "%1" /o /hardlink /nocompress /i:%1\USMTFiles\%3\MigUser.xml /i:%1\USMTFiles\%3\MigApp.xml /localonly /l:%4\ScanState.log /v:5 /progress:%4\ScanStateProgress.log /c /efs:hardlink

REM ======================================================
REM EXIT Errorlevel
REM ======================================================

EXIT /b %errorlevel%

RunScanState_WinPE.BAT

REM ======================================================
REM ARGUMENT -1- OSDStateStorePath     = %1
REM ARGUMENT -2- WindowsPartition    = %2
REM ARGUMENT -3- Architecture        = %3
REM ARGUMENT -4- LogDirectory        = %4
REM ======================================================

SET USMT_WORKING_DIR=%1\USMTFiles\%3

REM ======================================================
REM RUN Scanstate
REM ======================================================

"%1\USMTFiles\%3\Scanstate.exe" "%1" /o /hardlink /nocompress /i:%1\USMTFiles\%3\MigUser.xml /i:%1\USMTFiles\%3\MigApp.xml /offlinewindir:%2\Windows /localonly /l:%4\Scanstate.log /v:5 /progress:%4\Scanstateprogress.log /c /efs:hardlink

REM ======================================================
REM EXIT Errorlevel
REM ======================================================

EXIT /b %errorlevel%

The changes that I made in Part 1: Capture User Files and Settings are the following two:

  1. I use now a batch-file for both, and Online and Offline Capture.
    Why? Just because it gives me more flexibility and because I can get rid of a few “double” steps. For example, now I can use the same Store Location (variable) for both Captures Types.
  2. I use now a different location for the logfiles.
    Why? Just because it gives me an easy possibility to save the log until the end of the Task Sequence.

Part 2: Restore User Files and Settings

After the User Files and Settings have been captured, they need to be restored again to the new OS. This is the same for an Online and Offline Capture. Under here I will sum up the steps that I use to restore the Files and Settings:

  • Restore User Files and Settings – Run Command Line
    This step does the actual Restore of the User Files and Settings by running the Command line RunLoadState.BAT %OSDStateStorePath% %WindowsPartition% %Architecture% %_SMSTSLogPath% which has to start in the directory %OSDStateStorePath%\USMTFiles\..
  • Cleanup State Store Location – Run Command Line 
    This step cleans up the State Store Location by running the command line RunUSMTutils.BAT %OSDStateStorePath% %Architecture%
  • Restart in FullOS – Restart Computer (see the second red rectangle in the picture)
    This step will restart the computer, but only when _SMSTSLastActionRetCode is equal to 2.

These are all the steps I need, to do a Restore with Hard-Links. Now let’s take a look at the batch-files which do most of the work here:

RunLoadState.BAT

REM ======================================================
REM ARGUMENT -1- OSDStateStorePath     = %1
REM ARGUMENT -2- WindowsPartition    = %2
REM ARGUMENT -3- Architecture        = %3
REM ARGUMENT -4- LogDirectory        = %4
REM ======================================================

SET USMT_WORKING_DIR=%1\USMTFiles\%3

REM ======================================================
REM RUN LoadState
REM ======================================================

"%1\USMTFiles\%3\Loadstate.exe" "%1" /hardlink /nocompress /lac /i:%1\USMTFiles\%3\MigUser.xml /i:%1\USMTFiles\%3\MigApp.xml /l:%4\LoadState.log /v:5 /progress:%4\LoadStateProgress.log /c

REM ======================================================
REM EXIT Errorlevel
REM ======================================================

EXIT /b %errorlevel%

RunUSMTutils.BAT

REM ====================================================== 
REM VARIABLE -1- OSDStateStorePath = %1
REM VARIABLE -2- Architecture = %2
REM ======================================================

REM ======================================================
REM RUN USMTUtils
REM ======================================================

echo y| "%~dp0%2\usmtutils.exe" /rd "%1"

REM ======================================================
REM EXIT Errorlevel
REM ======================================================

EXIT /b %errorlevel%

The changes that I made in Part 2: Restore User Files and Settings are the following two:

  1. I use now also batch-file for the Restore.
    Why? Just because it gives me more flexibility and because I can get rid of a “double” step (setting the Hardlink options).
  2. I use now an optional restart of the computer.
    Why? Because I noticed that sometimes USMTUtils ends with code 2, which means that it needs a restart to get rid of the last files.

Note: The RunScanState_FullOS.BAT, RunScanState_WinPE.BAT, RunLoadState.BATand the RunUSMTutils.BAT have to be placed inside the USMT Package at the same level as the amd64- and the x86-folder.

More information about the Scanstate Syntax:
http://technet.microsoft.com/en-us/library/dd560781(WS.10).aspx
More information about the LoadState Syntax:
http://technet.microsoft.com/en-us/library/dd560804(WS.10).aspx
More information about the USMTUtils Syntax: http://technet.microsoft.com/en-us/library/dd560799(WS.10).aspx

User Driven Installation with ConfigMgr 2007 and MDT 2010 Update 1

UDI_WizardA few months ago I wrote a post about User Driven OS Deployment "Modena". By then it wasn’t sure if it was going to be released to the big public. Well I can tell now (after finally looking around in the the MDT 2010 Update 1 Beta) that it is going to be released, as it is a part of the MDT 2010 Update 1 (Beta).

Of course the scripts are now made to fit with the other MDT scripts, but the look-and-feel is the same (see picture).

This means that there is now an easy way coming for everyone to get their users “involved” in an OS Deployment. The only requirements are to have ConfigMgr 2007 and MDT 2010 Update 1 (Beta) installed and to have the ConfigMgr Integration configured.

How to create a User Driven Installation Task SequenceUDI_TaskSequence

  1. Open the Configuration Manager console and browse to System Center Configuration Manager > Site Database > Computer Management > Operating System Deployement > Task Sequences.
  2. Select Create Microsoft Deployment Task Sequence in the Actions pane.
  3. Select User Driven Installation Task Sequence and click Next (see picture). After this run, through the wizard an its done!

 

To keep a short story short, take a look at Microsoft Connect to get MDT 2010 Update 1 (Beta): 
>> https://connect.microsoft.com/site14 <<

ConfigMgr 2007 and editing the registry during a Task Sequence on a 64-bit OS

Disable64bitTSOf course you know, deep down, that the ConfigMgr 2007 Client is 32-bit and that it will react a bit different on a 64-bit OS. The reason for this is of course the emulation layer, also know as Windows 32-bit On Windows 64-bit (WOW64), that enables a 32-bit application to run seamlessly on a 64-bit OS. 

As the ConfigMgr 2007 (RTM, SP1, SP2) Client is only available in a 32-bit version, you may run into some bumps on a 64-bit Operation System. One of these bumps is editing a registry key in HKEY_LOCAL_MACHINE\Software, because, for the ConfigMgr 2007 Client, this will get redirected to HKEY_LOCAL_MACHINE\Software\WOW6432Node.

Luckily there is an easy solution for this in a Task Sequence of ConfigMgr 2007. Just create a Task Sequence, add a Run Command Line –step and select Disable 64-bit file system redirection. This will makes sure that the use of the WOW64 file redirector will be disabled. 

Example UserName_on_ComputerName
An often used registry edit is to rename the Computer (on XP this is My Computer) to “Username on Computername”. To do this you need to edit the  HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\LocalizedString –key. Without disabling the 64-bit file system redirection, the ConfigMgr 2007 Client will only change the key under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\LocalizedString. This will not make the change show in the menu or the explorer.

More information about the Run Command Line –step: http://technet.microsoft.com/en-us/library/bb632992.aspx
More information about WOW64, Registry (and File System) Redirection and Reflection: http://www.microsoft.com/whdc/system/platform/64bit/WoW64_bestprac.mspx

Using USMTUtils.exe during a Task Sequence with ConfigMgr 2007

As I had a lot of questions about the use of USMTUtils, I decided to devote a new post to this. In my previous post I used USMTUtils to clean up the hard-link statestore location.

USMTUtils is needed to clean up a hard-link statestore, because otherwise the hard-link store cannot be deleted due to a sharing lock. The command-line provided by Technet to do this is usmtutils.exe /rd <storedirectory>. Only this is exactly where the problem starts when running a command like this during a Task Sequence, because this will make the Task Sequence “hang” on the point where it has to delete the hard-link statestore. Taking a look at the SMSTS.log, at this point, will show something similar to this:

<![LOG[Executing command line: Run command line]LOG]!><time="14:56:41.804+-60" date="03-23-2010" component="InstallSoftware" context="" type="1" thread="2904" file="commandline.cpp:805">
<![LOG[]LOG]!><time="14:56:42.148+-60" date="03-23-2010" component="InstallSoftware" context="" type="1" thread="2904" file="runcommandline.cpp:34">
<![LOG[WARNING: This command is going to delete the following list of path(s).]LOG]!><time="14:56:42.195+-60" date="03-23-2010" component="InstallSoftware" context="" type="1" thread="2904" file="runcommandline.cpp:34">
<![LOG[Please review before continuing …]LOG]!><time="14:56:42.195+-60" date="03-23-2010" component="InstallSoftware" context="" type="1" thread="2904" file="runcommandline.cpp:34">

After this I just tried running the command-line manually from a cmd in Windows and this showed the following information:

WARNING: This command is going to delete the following list of path(s).
Please review before continuing …

        C:\<storedirectory>

Are you sure you want to proceed (Y/N)?

The conclusion here is that running the command-line usmtutils.exe /rd <storedirectory> will need a confirmation. This is the point where we have to grab back to a batch-file, so we can pipeline a positive response to the question asked by the USMTUtils. This can be done by using echo y|. So the batch-file, that we need to run the USMTUtils from a Task Sequence (with ConfigMgr 2007), has to include the command-line echo y| usmtutils.exe /rd <storedirectory>.

I hope this post gives a bit more inside information of why it is needed to pipeline a confirmation with the use of USMTUTils.

Capture User Files and Settings in Offline Mode (WinPE) with ConfigMgr 2007

In a previous postI already showed how to do a Hard-Link migration, when started from FullOS. That part still exists in my Task Sequence, but it is now moved under the Group Capture User Files and Settings – FullOS. This part will now only run when the Task Sequence is started from FullOS.

In this post I will add a part to the Task Sequence that makes sure that the User State will also be captured,  HardLinkOfflineTS when the Task Sequence is started from WinPE (also called Offline Mode). The cool part is that it will also be done by/ with using Hard-Links!

Capture User Files and Settings

For creating a Task Sequence, that does an Offline Capture, my way, a few variables and locations need to be created. After that a command line has to be run to do the actual Capture. Under here I will sum up the steps I take to do an Offline Capture (also see the red rectangle in the picture):

  • Set Started in WinPE – Set Task Sequence Variable
    This step sets the Task Sequence Variable TSStartedInWinPE to YES. This Task Sequence Variable only gets set when _SMSTSInWinPE is TRUE.
  • Capture User Files and Settings – WinPE – Group
    This group Captures the User Files and Settings when the machine is started from WinPE. This is done by checking if the Task Sequence Variable TSStartedInWinPE is set to YES.
  • Set Architecture – Set Task Sequence Variable
    This step sets the Task Sequence Variable Architecture to amd64. This variable will be used for selecting the USMT 4.0 version for 64-bit systems.
  • Set Windows Partition – Set Task Sequence Variable
    This step sets the Task Sequence Variable WindowsPartition to C:. This variable will be used for selecting the Windows partition.
  • Set State Store Location – Set Task Sequence Variable
    This step sets the Task Sequence Variable OSDStateStorePath to %WindowsPartition%\StateStore. This variable will be used for creating and selecting the User State Location.
  • Create State Store Location – Run Command Line
    This step creates the directory %WindowsPartition%\StateStore by running the Command line: cmd /c MKDIR %OSDStateStorePath%.
  • Cache USMT Files and Scripts – Run Command Line
    This step caches the USMT Files and Scripts from the USMT Package to the directory %OSDStateStorePath%\USMTFiles\ by running the Command line: xcopy * %OSDStateStorePath%\USMTFiles\ /herciy
  • Capture User Files and Settings – Run Command Line
    This step does the actual Capture of the User Files and Settings by running the Command line RunScanState.BAT %OSDStateStorePath% %WindowsPartition% %Architecture% which has to start in the directory %OSDStateStorePath%\USMTFiles\.

These are all the steps I need, to do an Offline Capture with Hard-Links. Now let’s take a closer look at the batch-file which does most of the work.

REM ============================================================
REM VARIABLE -1- OSDStateStorePath = %1
REM VARIABLE -2- WindowsPartition = %2
REM VARIABLE -3- Architecture = %3
REM ============================================================

SET USMT_WORKING_DIR=%1\USMTFiles\%3

REM ============================================================
REM RUN Scanstate
REM ============================================================

“%1\USMTFiles\%3\Scanstate.exe” “%1” /o /hardlink /nocompress /i:%1\USMTFiles\%3\miguser.xml i:%1\USMTFiles\%3\migapp.xml /offilinewindir:%2\Windows\TEMP\SMSTSLog\Scanstate.log /v:5 /progress:%2\Windows\TEMP\SMSTSLog\Scanstateprogress.log /c /efs:hardlink

REM ============================================================
REM EXIT Errorlevel
REM ============================================================

EXIT /b %errorlevel%

In this batch-file I am using three variables which are being set during the Task Sequence (and explained in the batch). The Scanstate command line, that is being used, is completely based on the standard syntax. Under here I created a table in which can be seen what every part of my command line stands for.

Command What does it do…
%1\USMTFiles\%3\scanstate.exe Scanstate.exe
%1 Specifies the folder where files and settings will be saved
/o Enables the possibility to overwrite existing data in de Migration Store.
/hardlink Enables the creation of a Hard-Link Migration Store
/nocompress Disables the compression of data.
/i:%1\USMTFiles\%3\miguser.xml Specifies an .xml file that contains rules that define what user, application or system state to migrate
/i:%1\USMTFiles\%3\migapp.xml Specifies an .xml file that contains rules that define what user, application or system state to migrate
/offlinewindir:%2\windows Specifies the Offline Windows directory that the ScanState command gathers user state from
/l:%2\windows\TEMP\SMSTSLog\Scanstate.log Specifies the location and name of the ScanState log
/v:5 Enables the verbose output in the ScanState log file
/progress:%2\windows\TEMP\SMSTSLog\Scanstateprogress.log Specifies the location and name of the ScanState progress log
/c Enables the ScanState command to continue to run, even if non-fatal errors occur
/efs:hardlink Enables the migration of encrypted files by creating a Hard-Link to the EFS file instead of copying it

Restore User Files and Settings

After the User Files and Settings have been captured, they need to be restored again to the new OS. For this I use the default Restore User Files and Settings step from ConfigMgr 2007 and the variable OSDMigrateAdditionalRestoreOptions. This variable is filled with the options /nocompress /hardlink, see for this also my previous post. This default step will restore everything that is found in the State Store Location.

With the red arrow in the picture I point at another important step (which is often forgotten). This step is the Cleanup User State Location, a Run Command Line step from ConfigMgr 2007. This step cleans up the State Store Location by running the command line RunUSMTutils.BAT %OSDStateStorePath% %Architecture% from the USMT 4.0 Package.

Now let’s take a look at the batch-file which does most of the work here.

REM ============================================================
REM VARIABLE -1- OSDStateStorePath = %1
REM VARIABLE -2- Architecture = %2
REM ============================================================

REM ============================================================
REM RUN USMTUtils
REM ============================================================

echo y| “%~dp0%2\usmtutils.exe” /rd “%1”

REM ============================================================
REM EXIT Errorlevel
REM ============================================================

EXIT /b %errorlevel%

The important part in here is the echo y|, because only running umstutils.exe /rd will ask for a confirmation on the action. I have to say that I really missed this in the documentation! So just use echo y| to pipeline a positive response on the confirmation, asked by the usmtutils.

Note: The RunScanState.BAT and the RunUSMTutils.BAT have to be placed inside the USMT Package at the same level as the amd64- and the x86-folder.

More information about the Scanstate Syntax:
http://technet.microsoft.com/en-us/library/dd560781(WS.10).aspx
More information about the LoadState Syntax:
http://technet.microsoft.com/en-us/library/dd560804(WS.10).aspx
More information about the USMTUtils Syntax: http://technet.microsoft.com/en-us/library/dd560799(WS.10).aspx

User Driven OS Deployment with “Modena”

It took a while but this weekend it was finally time for some testing of, what’s code-named, “Modena”. Modena is a tool, developed by Microsoft IT, that enables the ability of an End-User Experience by using a powerful OSD Wizard.

ModWelcWhen you are searching for a way to get your users “involved” in an OS Deployment, then I would recommend you to take a look at Modena. The OSD Wizard of Modena (see picture) can be changed in a lot of different way’s. As an administrator you can select which settings can be done by a user and which are pre-set. By these customizable settings you can think about things like computername, domain, local administrators, language, time, image, backup (via USMT 4.0) and the applications. The nice thing about the applications is that you can first do a scan of the computer to see what applications are currently installed. Based on the results of this scan, applications can get pre-selected (or not). Besides al of these settings Modena also provides a better insight in what is happening with the computer during the Task Sequence.

To make a long story short, take a look at Microsoft Connect to get Modena: 
>> https://connect.microsoft.com/site868 <<

Also take a look at the following links for setting up Modena…
1. Getting started with Modena – Step 1 – Installing Modena: http://blogs.technet.com/osd/archive/2009/12/15/getting-started-with-modena-step-1-installing-modena-rc2.aspx
2. Getting started with Modena – Step 2 – Create OSD Packages: http://blogs.technet.com/osd/archive/2009/12/16/getting-started-with-modena-step-2-create-osd-packages.aspx
3. Getting started with Modena – Step 3 – Importing Task Sequences: http://blogs.technet.com/osd/archive/2009/12/17/getting-started-with-modena-step-3-importing-task-sequence.aspx
4. Getting started with Modena – Step 4 –Introduction to OSD Designer: http://blogs.technet.com/osd/archive/2009/12/17/getting-started-with-modena-step-4-introduction-to-osd-designer.aspx
5. Getting started with Modena – Step 5 – Using Modena Online Services: http://blogs.technet.com/osd/archive/2009/12/18/getting-started-with-modena-step-5-using-modena-online-services.aspx
6. Getting started with Modena – Step 6 – Setting Up Applications: http://blogs.technet.com/osd/archive/2009/12/28/getting-started-with-modena-step-6-setting-up-applications.aspx

…and take a look at these links for the story behind Modena.
General Cravings of OSD: http://blogs.technet.com/osd/
Windows 7 Deployment Guide: http://technet.microsoft.com/en-us/magazine/ee676738.aspx