Share via


Logging All the Configuration Manager Task Sequence Variables

When debugging a MDT based Configuration Manager Task Sequence, it is often helpful to know what certain built-in Configuration Manager variables are set to during a step in the task sequence. For instance, you may want to see if _SMSTSLastActionRetCode was equal to a certain value or perhaps which management point the client is using by checking _SMSTSMP. These variables and more are available in the Microsoft.SMS.TSEnvironment and you can easily log them using the script snippet below:

Dim sVar

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

For Each sVar in osdv4.GetVariables()
oLogging.CreateEntry sVar & ":" & oEnvironment.Item(sVar), LogTypeInfo
Next

A list of the variables and their values can be found at https://technet.microsoft.com/en-us/library/bb632442.aspx .

The full ZTI-style script is included below. Add the script to the Microsoft Deployment Toolkit package and you can call this script as a task in the task sequence. The variables will be outputted to OutputTSVariables.log.

Try it out and feel free to comment.

This post was contributed by Aly Shivji a consultant with Microsoft Services - U.S. East Region.

OutputTSVariables.zip

Comments

  • Anonymous
    January 01, 2003
    183 Microsoft Team blogs searched, 87 blogs have new articles in the past 7 days. 205 new articles found

  • Anonymous
    January 01, 2003
    183 Microsoft Team blogs searched, 87 blogs have new articles in the past 7 days. 205 new articles found

  • Anonymous
    January 01, 2003
    When troubleshooting TS’s or when you simply want to know what is all being used in the TS, it can be

  • Anonymous
    January 01, 2003
    So apologies to all - credit to Frank Rojas for discovering this. The posted script had a typo - it was using a curly quote instead of straight quote and was probably when it was copied and pasted. Remember there is also a new and improved version in the second installment of this post.

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    October 16, 2008
    The comment has been removed

  • Anonymous
    September 17, 2009
    Hi I tried to implement something very similair but in Powershell and got lost. Are you able to provide the same script snippet in Powershell? Here is my first part to get the variables. I am able to create a list of variables but what is the syntax to get the values? $TSEnv=New-Object -comobject Microsoft.SMS.TSEnvironment" foreach ($TSVar in $TSEnv.GetVariables() { $TSVar #That's only the name!! $TSVar._SMSLogPath # VALUE ?!???? } Another issue is I want to set application variables. The problem is the same. I am not sure about the Syntax. In a VBScript $TSVar("OSDComputerName") works. But what about Powershell? $TSEnv("Variable")=xyz $TSEnv.Variable=xvz or can I access the variables via the standard $env variable? $env:Variable Any suggestion would be nice. Best Regards Joachim

  • Anonymous
    November 08, 2010
    The comment has been removed

  • Anonymous
    September 21, 2011
    Seems there is a disconnect. Where are we initializing "oLogging" object before we can call "oLogging.CreateEntry". I can't see what can this object can possibly be and what is the ", LogTypeInfo" doing there. Someone has to revisit this article and write probably few more lines to make all these meaningful.