Finding All References to MDT Variables in a Deployment Share: VariableDocumentor v1.0


MDT is very flexible in the ability to define and use variables inline and in different locations. However, this also means that if you forget to assign a variable a value it may lead to unintended consequences that you might not easily discover. There are many different places in which you could find references to a variable:

  • Task Sequence Variables- You can use variables in a task sequence in two ways:
    • Directly used in the command line with the notation %variable%
    • As a condition on a particular step in the task sequence
  • ZTIGather.xml – This file defines the variables and lists that are declared by MDT for the Gather step of the Task Sequence to use and process for rules. It also defines whether variables are re-writable.
  • Within MDT scriptsvariables are called in different ways
    • In VBScripts you may see a reference to an oEnvironment.Item or an oEnvironment.ListItem
    • In Powershell you may see references to tsenv: or tsenvlist:
    • In cmd and batch scripts you may see references to %variable%
  • In a CustomSettings or other INI file you could see references to variables in the “Properties=” field

In order to help manage all of these variables, the following PowerShell script scours a given deployment share


and returns the results of all references from scripts, task sequences and ZTIGather of variables in that deployment share. It saves it to a Variables.XML with a built in XSL transform in the working directory:


You can also specify a parameter to update a given INI to see any variables missing from the properties section.


To use it – download the attached Powershell and XSL and point to the same folder.

This post was contributed by Aly Shivji, an Architect with the Datacenter & Private Cloud Center of Excellence in Microsoft Services

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