Some basic USMT 4.0 actions explained

The last few weeks a saw and got a lot of questions about capturing specific files and folders with USMT. These actions are actually quite basic and good documented on Technet, but still seem to raise a lot of questions. So I decided to devote a post to this. I will show some examples and will try to explain what it all means. Let’s start with a component that migrates all files in a specific folder.

<component type=”Documents” context=”System”> 
<displayName>Component to migrate all files in a specific folder including subfolders</displayName> 
   <role role=”Data”> 
      <rules> 
         <include> 
            <objectSet> 
               <pattern type=”File”>C:\SpecificFolder\* [*]</pattern> 
            </objectSet> 
         </include> 
      </rules>
   </role>
</component>

Well, that’s a nice component but what does it all mean? Let’s go through it line-by-line

<component type=”Documents” context=”System”> </component>

The <component> element is a required element in a custom .xml and describes the basic construct. After that the component type specifies the kind of files that will be captured. In this case it’s the documents, which actually includes almost all files. At last the component context specifies the scope of the capture. The scope can also be set in the <rules> element, but largest scope is defined in the <component> element. In this case the context is the whole operating system.

<displayName>Component to migrate all file in a specific folder including subfolders</displayName>

The <displayName> element is a required element within a <component> element. This name will show up in a config.xml as a component that can be enabled during migration.

<role role=”Data”>

The <role> element is a required element in a custom .xml and is used to concrete the component. The parameters used in this element do NOT change the migration behavior and are only used for categorizing the migration settings.

<rules><include><objectSet><pattern type=”File”>C:\SpecificFolder\* [*]</pattern></objectSet></include></rules>

The <rules> element is a required element in a custom .xml and contains all the rules that will be run during a migration.

The <include> element is a required element within a <rules> element and determines what will be migrated.

The <objectSet> element is a required element within a <include> element and contains the list of the specific objects that need to be migrated. This can be anything from registry keys until specific files. In this example it contains all the documents and files within C:\SpecificFolder\. By specifying the * it migrates all the subfolders and by specifying [*] also migrates all the files. To find only a specific file in the specific folder and subfolders change the * between the brackets for the name of the specific file.

Well, that hopefully already explains a lot, but what if we also want to exclude some files? To exclude a specific file or folder add an <exclude> element to the <rules> element, to specify which file and/ or folder should be excluded from the migration. To exclude SpecificFile.txt from somewhere in the SpecificFolder, the .xml file would go look like this.

<component type=”Documents” context=”System”>
<displayName>Component to migrate all Documents in a specific folder including subfolders</displayName>
   <role role=”Data”>
      <rules>
         <include>
            <objectSet>
               <pattern type=”File”>C:\SpecificFolder\* [*]</pattern> 
            </objectSet>
         </include>
         <exclude>
            <objectSet>
               <pattern type=”File”>C:\SpecificFolder\* [SpecificFile.txt]</pattern> 
            </objectSet> 
         </exclude>
      </rules>
   </role>
</component>

Well, that hopefully already gives some more possibilities, but what if we also want to migrate these specific files and folders to a different location on the destination machine? To migrate to a different location add a <locationModify> element to the <rules> element. This element only gets evaluated during the loadstate. By using the RelativeMode script and specifying the specific files and/ or folders in the <objectSet> element, it can move files and folders from the location on the source machine the a new location on the destination machine. To move the C:\SpecificFolder contents to C:\Temp the .xml would go look like this.

<component type=”Documents” context=”System”>
<displayName>Component to migrate all Documents in a specific folder including subfolders</displayName>
   <role role=”Data”>
      <rules>
         <include>
            <objectSet>
               <pattern type=”File”>C:\SpecificFolder\* [*]</pattern> 
            </objectSet> 
         </include>
         <locationModify script=”MigXmlHelper.RelativeMove(‘C:\SpecificFolder\’, ‘C:\Temp\’)”>
            <objectSet>
               <pattern type=”File”>C:\SpecificFolder\* [*]</pattern>
            </objectSet>
         </locationModify>
      </rules>
   </role>
</component>

See for the whole XML Elements Library: http://technet.microsoft.com/en-us/library/dd560769(v=ws.10).aspx

Leave a Comment

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