You are here:   Research
  |  Login

Welcome to my blog, quickest way to find articles is usually to search for them.

Search in All Title Contents

Creating custom variables in MDT 2013

Aug 12 2014

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 Files\Microsoft Deployment Toolkit\Bin\Microsoft Deployment Toolkit Documentation Library.chm (default location).

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:

<!-- Properties that can be overwritten (last value wins) and are automatically set by the BDD scripts -->
<property description="The UNC path to the deployment share" overwrite="true" type="string" id="DeployRoot"/>
<property description="The drive letter mapped to the deployment share (Lite Touch only)" overwrite="true" type="string" id="DeployDrive"/>

<!-- Properties that cannot be overwritten (first value wins) -->
<property description="The new computer name to assign to the computer (used with ConfigMgr) " overwrite="false" type="string" id="OSDComputerName"/>
<property description="TimeZone Identifier for Windows Vista Builds (example: PST = 'Pacific Standard Time')" overwrite="false" type="string" id="TimeZoneName"/>


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

Priority=HardwareInfo, Default
Properties=MakeAlias, ModelAlias



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.

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.

<job id="ZTISetVariable">
    <script language="VBScript" src="ZTIUtility.vbs"/>
    <script language="VBScript">

    ' Create and set a custom varialble
    oEnvironment.Item("HydrationMethod") = "Simulate"



Happy deployment, Johan

Deployment News

Happy deployment, and thanks for reading!

What our lawyers makes us say:

This information is provided "AS IS" with no warranties, confers no rights and is not supported by the authors or Deployment Artist.

Copyright © 2017 by Deployment Artist (the company behind deployment research). All rights reserved. No part of the information on this web site may be reproduced or posted in any form or by any means without the prior written permission of the publisher.

Shorthand: Don't pass off our work as yours, it's not nice.

Blog Archive


Where you can meet us!

Live Stream Recordings
ConfigMgr 1806 and W10 OSD

5 Days - Mega Geek Week 
(multiple classes, ConfigMgr, OSD etc.)
- Johan Arwidmark, Mikael Nystrom...
Jun 10, 2019, Chicago, IL, US

4 Days - Windows 10 OSD Classes
- Johan Arwidmark
May 20, 2019, San Diego, CA, US
Jun 17, 2019, Culemborg, NL
Jul 8, 2019, Phoenix, AZ, US

5 days - ConfigMgr Classes
- Johan Arwidmark and Kent Agerlund
Apr 8, 2019, Chicago, IL, US
Apr 22, 2019, Houston, TX, US

Video-based trainings

MDT, Windows 10 and ConfigMgr Books

Contact Info