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:
oEnvironment.Substitute(sVal)
Given a string, will expand any variables and/or functions within that string.
oEnvironment.ListItem(sName)
Read/Write a variable of type array to a persistent store.
how do I use this variable to detect a vm and if is a vm then create a extra disk partition?
LikeLike
You wouldn’t write a script for that. Read my post MDT 2012: Targeting Lite-Touch Deployments.
LikeLike
The variable IsVM. Is what I am referring to. When I set this variable = true then, I need to create a separate volume on the vm. However when i create the shell with two hard disk 1= 60GB and 2= 10GB. The diskpart script that I associated with this deployment does not inialize the disk. Is there a better way to create a separate 10GB partition if it is a VM?
LikeLike
There is no need to use VB for this. You can test for a vm using task sequence variables https://scriptimus.wordpress.com/2011/06/16/mdt-2010-task-sequence-conditions/
In your task sequence create a second “Format and Partition Disk” step and customise them both.
Then apply conditions to both.
That’s the easiest way I’d handle it.
Andrew.
LikeLike