• Home  / 
  • Research
  •  /  Creating custom variables in MDT 2013

Creating custom variables in MDT 2013

Yesterday I got a question in my twitter feed (@jarwidmark) about how to create a custom variable in MDT 2013 using a script. The answer is, yes you can do that, but you rarely have to, because you can create them directly in CustomSettings.ini to begin with. Anyway, some times it does makes sense to dynamically create custom variables in a script. In this post I demonstrate a few different methods for creating a custom variable.

Going back to the source

First, built-in variables are documented in the MDT 2013 help file, found via the Deployment Workbench "Help" menu, or in the file system: C:Program FilesMicrosoft Deployment ToolkitBinMicrosoft Deployment Toolkit Documentation Library.chm (default location).

image
The MDT 2013 help file.

Then MDT has it's internal "document", the ZTIGather.xml file that lists the variables, and also defines their behavior. For example if a property should have "first-writer-wins" or "last-writer-wins". Here are few sample lines from the ZTIGather.xml file:







 

Creating a custom variable using CustomSettings.ini

The most commonly used method to create a custom variable is to add it to your CustomSettings.ini file. Here is an example, where two custom variables (or properties) are used for

[Settings]
Priority=HardwareInfo, Default
Properties=MakeAlias, ModelAlias

[HardwareInfo]
UserExit=ModelAliasExit.vbs
MakeAlias=#SetMakeAlias()#
ModelAlias=#SetModelAlias()#

 

Creating a custom variable in the Task Sequence

Variables set in CustomSettings.ini are considered global by default, but you can create task sequence specific variable directly in the task sequence by adding a "Set Task Sequence Variable" action. Here is an example showing the custom HydrationMethod variable in a task sequence.

image

Adding a custom variable to a task sequence.

 

Creating a custom variable in a script

When needing variables created (or set) in a script, for example based on dynamic conditions, you can do that too by simply calling the task sequence object. This is exactly what the built-in ZTISetVariable.wsf script does, but you also find that most of the other MDT scripts do that as well.


    

 

Happy deployment, Johan

About the author

Johan Arwidmark

5
Leave a Reply

avatar
5 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
kantzyAdminITguyCharlie Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
kantzy
Guest
kantzy

Figured out how to change the language based on the a custom variable we are setting in the wizard. Added the below in CS.ini and modified the Gather step in the TS to gather variables in CS.ini after the HTA wizard. Thanks for all you contribution. You guys rock.
[Settings]
Priority=LanguagePack, Default

[French]
LanguagePacks001={1c0991b3-2511-43ca-998c-e6ef31d7c950}

kantzy
Guest
kantzy

We have a custom wizard for Windows 7 created in MDT 2010 integrated with SCCM 2007. I have somehow managed to get the same wizard in MDT 2013 using which we will be deploying Windows 8.1 for tablets (without SCCM).In the HTA wizard we select a location based on which language, locale, time zone etc are auto selected. Language pack has a custom variable called "LanguagePack".Even UILanguage is set with the same values as "LanguagePack" variable (Just FYI) Can you please let me know how to install a specific language pack based on this custom variable called "LanguagePack"?Do i need… Read more »

ITguyCharlie
Guest
ITguyCharlie

Lest we not forget, can always call some custom variables from the command line "Litetouch.wsf /TaskSequenceID:REF-BUILD /CustomVar:CUSTOM" Though more used for static variables, assuming Litetouch is called from some other script can always pass in dynamic variables too…


>