MDT Scripting: Managing Environment Variables – Part 1

Continuing my scripting series, the ZTIUtility.vbs file has a massive list of functions that can be used to save you the work of creating scripts from scratch. Used in combination with the MDT Template Script you can knock up a working script in minutes that would normally take hours to put together.

MDT collects a lot of environment information. This data can be used in your deployments to make your work a lot easier. Remember, you can get a list of the properties in the ZTIGather.xml file. The Properties and Values are stored in the variables.dat file. You can open this file in a text editor and examine the information that MDT is collecting/using.

Today’s examples will focus on using the ZTIUtility Environment Class. I will assume you have read my getting started article here and are following on. This class is used for collecting or changing properties gathered by MDT. You can base your scripts around these values and produce conditions accordingly.

To write a Property value.

The MDT properties are stored as variables in the file variables.dat and can be manipulated using the oEnvironment.Item method. The example code below changes the computer name to be used. Enter the example code below into your MDT template:

oEnvironment.Item("OSDComputerName") = "PC-01"

If run from a command prompt you will see this:

The same line will appear in the BDD.log file. You can change the value of most properties but should be aware that some are properties are read only with good reason.

About Andrew Barnes

A Scripting and Deployment Specialist.
This entry was posted in MDT 2010, SCCM, Scripting and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s