List Task Sequence Variables in SCCM 2012

When troubleshooting OSD in SCCM 2012 it's quite useful to enumerate the various task sequence variables. Here are twos script that does that, one in VBScript, one in PowerShell.

The EnumTSVariables.vbs script

By default the script simple outputs to the console, but you can easily pipe the result to a text file:
cscript EnumTSVariables.vbs > X:\Windows\Temp\TSResult.txt

Dim oTSEnv 
Dim oVar

Set oTSEnv = CreateObject("Microsoft.SMS.TSEnvironment") 

For Each oVar In oTSEnv.GetVariables
	WScript.Echo " "
	WScript.Echo "  "& oVar & vbTab & oTSEnv(oVar) & vbTab

The EnumTSVariables.ps1 script

Here is the same thing, but using PowerShell.

$VarFile = X:\Windows\Temp\TSResult.txt
$TSEnv = New-Object -ComObject Microsoft.SMS.TSEnvironment

$Vars = $TSEnv.GetVariables()
$Output = foreach ($Var in $Vars)
    '{0} = {1}' -f $Var, $TSEnv.Value($Var)
$Output | Out-File -FilePath $VarFile

Happy Deployment

/ Johan

About the author

Johan Arwidmark

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments