Continuing with the ZTIUtility Environment Class. I again will assume you have read my getting started article here or have basic knowledge of MDT scripting. This class is used for collecting or changing properties gathered by MDT. You can produce scripts and conditions based around these values.
To Read a value and detect information.
Yesterday we used oEnvironment.Item(sName) to update a property value. We can also use the same method to return a value. oEnvironment.Exists(sName) is used to check if a property is not empty. This example will demonstrate both methods. To begin with paste this example code in your MDT Script Template:
If oEnvironment.Exists("_SMSTSORGNAME") then wscript.echo "The Property Value = " & oEnvironment.Item("_SMSTSORGNAME") Else wscript.echo "The Property Value is not set!" End if
If the _SMSTSORGNAME value has not been set in the customsettings.ini then the script will detect that the _SMSTSORGNAME property has no value and display the prompt as below.
Now, modify the code to use the IsVM property as below and run the script again.
If oEnvironment.Exists("IsVM") then wscript.echo "The Property Value = " & oEnvironment.Item("IsVM") Else wscript.echo "The Property Value is not set!" End if
This time it will return a Boolean value (True or False) depending on whether or not you’re running a virtual machine.
The other methods in the ZTIUtility Environment Class are:
Given a string, will expand any variables and/or functions within that string.
Read/Write a variable of type array to a persistent store.