"Easy" List Items for the Microsoft Deployment Toolkit

In MDT rules processing with CustomSettings.ini, some of the items that can be configured are List Items.  List Items are essentially multi-valued custom properties.  Examples of items that are List Items are Applications in LTI and Packages in ZTI.  To define a List Item based property in CustomSettings.ini you add the base property name in the Properties line in the Settings section in the form Propertyname(*) if it is a custom List Item.  Then in the section(s) where you want the to define the values for the List Item, you add them in the form of either Propertyname1=value or Propertyname001=value.  The numeric suffix should start at 1 or 001 and increment by 1.  Below is the example for the Packages List Item property from the MDT help file:

[Settings]
Priority=Default

[Default]
Packages001=NYC00010:Install
Packages002=NYC00011:Install

 

Since this is an MDT-defined property, it does not need to be listed in the Properties line.  Below is an example of a custom List Item (additions in blue):

[Settings]
Priority=ExcludeRootFolders, Default
Properties=MyCustomProperty, UsmtExcludeRootFolders(*)

[Default]
OSInstall=Y

[ExcludeRootFolders]
UsmtExcludeRootFolders001=%ProfilesFolder%
UsmtExcludeRootFolders002=%ProgramData%
UsmtExcludeRootFolders003=%ProgramFiles%
UsmtExcludeRootFolders004=%windir%
UsmtExcludeRootFolders005=C:\_SMSTaskSequence
UsmtExcludeRootFolders006=C:\drivers
UsmtExcludeRootFolders007=C:\MININT
UsmtExcludeRootFolders008=C:\MSOCache
UsmtExcludeRootFolders009=C:\Temp
UsmtExcludeRootFolders010=C:\Winnt
UsmtExcludeRootFolders011=C:\Boot
UsmtExcludeRootFolders012=C:\System Volume Information
UsmtExcludeRootFolders013=C:\PerfLogs

The list of folders in this example is one of several lists that a custom script of mine consumes and generates a custom USMT XML file.  When I was first doing this with standard MDT List Items I found several things really frustrating.  The first was the numeric suffix.  The numeric suffix must be in numeric order and there must be no repeated numbers and no gaps in the number sequences.  If you don't do this, not all the items will be processed.  I like to keep the folders in alphabetical order so that when I need to add or remove one, it is easy to find the place to add, delete, and make sure I'm not adding a duplicate.  So when I have to add an item near the top of the list, painful tedious re-numbering would have to be done.

Also, MDT rules processing expands all variables in values placed on CustomSettings.ini.  So the special folder variables at the beginning of the list would get expanded to the value for that folder on the source OS.  However, I actually wanted the exact text (without variables being expanded) placed in the List Item.

So to get around these limitations I created a User Exit script to implement what I call Easy List Items.  Here is the previous example done as an Easy List Item (additions in green):

[Settings]
Priority=TestEasyListItem, Default
Properties=MyCustomProperty, AddUsmtExcludeRootFolders

[Default]
OSInstall=Y

[TestEasyListItem]
UserExit=EasyListItemExit.vbs
AddUsmtExcludeRootFolders=#AddToListItem("UsmtExcludeRootFolders", "ExcludeRootFolders", "", False)# 

[ExcludeRootFolders]
UsmtExcludeRootFolders=%ProfilesFolder%
UsmtExcludeRootFolders=%ProgramData%
UsmtExcludeRootFolders=%ProgramFiles%
UsmtExcludeRootFolders=%windir%
UsmtExcludeRootFolders=C:\_SMSTaskSequence
UsmtExcludeRootFolders=C:\Boot
UsmtExcludeRootFolders=C:\drivers
UsmtExcludeRootFolders=C:\MININT
UsmtExcludeRootFolders=C:\MSOCache
UsmtExcludeRootFolders=C:\PerfLogs
UsmtExcludeRootFolders=C:\Temp
UsmtExcludeRootFolders=C:\System Volume Information
UsmtExcludeRootFolders=C:\Winnt

As you can see from this example, the AddToListItem function in EasyListItemExit.vbs allows you to add all the List Item entries without the numeric suffix.  You can now reorder, add, and delete items without worrying about number order or gaps in the numbering.  And because this function simply adds to the List Item if it already exists, Easy List Items can coexist with standard MDT List Item entries.

The parameters for the function are the List Item name, the section to process for entries to add, the INI file path (blank for the current INI file), and True (expand variables) or False (don't expand variables).  The INI file parameter allows you to query additional INI files for entries.  In this example the custom property AddUsmtExcludeRootFolders that causes the AddToListItem function to run will have a value of Success or Failure (if the List Item entries, section name, or INI file cannot be found).

The script can be found in the Zip file below.

Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified in the Terms of Use .

This post was contributed by Michael Murgolo, a Senior Consultant with Microsoft Services - U.S. East Region.

EasyListItemExit.zip