Microsoft Deployment Toolkit
Documentation Library Use Task Sequence Variables Within Windows PowerShell Scripts |
Your Windows PowerShell script can get or set task sequence variables that can be consumed by MDT. You get or set task sequence variables using the following Windows PowerShell drives:
· TSENV:. This drive is a list of all the task sequence variables and their current values. You can access this drive as you would any other Windows drive. For example, you could type the following command within Windows PowerShell to list all the task sequence variables and their current values:
dir tsenv:
· TSENVLIST:. This drive lists all the task sequence variables and their current values as an array.
Note Any values in the TSENV: and TSENVLIST: drives are lost after the task sequence completes as any values are stored in memory and are not persisted after the task sequence finishes.
The following are examples that illustrate how to access task sequence variables using these drives:
· $tsenv:GPOPackPath ="\\WDG-MDT-01\Packages$\GPOPacks"
This command updates the ApplyGPOPack task sequence variable to "\\WDG-MDT-01\Packages$\GPOPacks"
· Write-Host $tsenv:ScriptRoot
This command displays the contents of the ScriptRoot task sequence variable to the Windows PowerShell console.
· $packages = $tsenvlist:PACKAGES
This command sets the $packages Windows PowerShell variable to the current value of the PACKAGES task sequence variable.
· $tsenvlist:PACKAGES = @("XXX00001:Program","XXX00002:Program")
This command sets the value of the PACKAGES task sequence variable to "XXX00001:Program","XXX00002:Program".
Related Topics