Dumping Task Sequence Variables


Several people asked me after the troubleshooting session I presented at MMS 2010 how to write a script to dump out all the task sequence variables.  Here are a few samples showing how to do just that.  (These examples work for ConfigMgr and MDT Lite Touch task sequences.)

First, the absolute “bare bones” approach:


Set env = CreateObject("Microsoft.SMS.TSEnvironment")
For each v in env.GetVariables
   WScript.Echo v & " = " & env(v)
Next


Save that as “DumpVar.vbs” and run it via the task sequence, redirecting the output to a text file.  For example, if you saved this script in the MDT “Scripts” folder, you could use a command line like this:

cmd.exe /c cscript.exe "%ScriptRoot%\DumpVar.vbs" >> %Temp%\DumpVar.txt

If you want to get fancier, you can use MDT’s logging capabilities:


<job id="ZTIConnect">
   <script language="VBScript" src="ZTIUtility.vbs"/>
   <script language="VBScript">

   Set env = CreateObject("Microsoft.SMS.TSEnvironment")
   For each v in env.GetVariables
      oLogging.CreateEntry v & " = " & env(v), LogTypeInfo
   Next

   </script>
</job>


Save that as “DumpVar.wsf” in the MDT “Scripts” folder, and run it with a simpler command line:

cscript.exe "%ScriptRoot%\DumpVar.wsf"

If you would prefer to use PowerShell, the same thing can be done with it:


# Determine where to do the logging
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$logPath = $tsenv.Value("_SMSTSLogPath")
$logFile = "$logPath\$($myInvocation.MyCommand).log"

# Start the logging
Start-Transcript $logFile

# Write all the variables and their values
$tsenv.GetVariables() | % { Write-Host "$_ = $($tsenv.Value($_))" }

# Stop logging
Stop-Transcript


Save that as “DumpVar.ps1” in the MDT “Scripts” folder, and run it using PowerShell.exe (as long as execution of scripts has been enabled):

PowerShell.exe –File "%ScriptRoot%\DumpVar.ps1"

Here are some related links:

http://blogs.technet.com/deploymentguys/archive/2008/08/29/outputting-all-the-configuration-manager-task-sequence-variables.aspx

http://blogs.technet.com/mniehaus/archive/2009/09/22/running-powershell-scripts-as-part-of-a-task-sequence.aspx

A few people commented on how they could see my Administrator account and password details in the output of the script I was running, as I had specified that account for my ConfigMgr network access account.  That’s definitely not a best practice – you should specify an account that has the minimum rights required, typically just enough to connect to your distribution point shares.  It should never have domain admin rights.  (Yes, I was lazy and just reused the only account I set up in my demo VMs.)

You might wonder why the example script above that uses ZTIUtility.vbs doesn’t log the password.  That’s because we have specific logic in that script that refuses to log any line that contains the word “password” as a security feature.


Comments (5)
  1. Anonymous says:

    Since many of our task sequence variables were useful reference items, I used a similar script to dump all of the variables to the registry, then went back and deleted any values that were known to contain sensitive information.  Great for troubleshooting failed builds, or having an "as built" record of important information (we used a LOT of custom variables for our builds).

  2. showbox says:

    Thanks for the great info. I really loved this. I would like to apprentice at the same time as you amend your web site, how could i subscribe for a blog site?
    For more info on showbox please refer below sites:
    http://showboxandroids.com/showbox-apk/
    http://showboxappandroid.com/
    Latest version of Showbox App download for all android smart phones and tablets.
    http://movieboxappdownloads.com/ – It’s just 2 MB file you can easily get it on your android device without much trouble. Showbox app was well designed application for android to watch movies and TV shows, Cartoons and many more such things on your smartphone.
    For showbox on iOS (iPhone/iPad), please read below articles:
    http://showboxappk.com/showbox-for-ipad-download/
    http://showboxappk.com/showbox-for-iphone/
    Showbox for PC articles:
    http://showboxandroids.com/showbox-for-pc/
    http://showboxappandroid.com/showbox-for-pc-download/
    http://showboxforpcs.com/
    There are countless for PC clients as it is essentially easy to understand, simple to introduce, gives continuous administration, effectively reasonable. it is accessible at completely free of expense i.e., there will be no establishment charges and after establishment
    it doesn’t charge cash for watching films and recordings. Not simply watching, it likewise offers alternative to download recordings and motion pictures. The accompanying are the strides that are to be taken after to introduce Showbox application on Android.
    The above all else thing to be done is, go to the Security Settings on your Android telephone, Scroll down and tap on ‘Obscure sources’.

  3. aw says:

    hai, I just want to tell you that I am just very new to blogs and seriously loved this website. More than likely I’m planning to bookmark your blog post .
    You amazingly come with really good posts. Thanks a lot for sharing your blog Microsoft.

    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Palembang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Papua
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Papua%20Barat
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Pati
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Pekalongan
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Pontianak
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Samarinda
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Semarang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Serang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Sidoarjo
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Surabaya
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Surakarta
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Tangerang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Tasikmalaya
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Yogyakarta
    http://www.lokerjobindo.com/search/label/Loker%20Jurusan%20Akunting
    http://www.lokerjobindo.com/search/label/Loker%20Jurusan%20Asuransi
    http://www.lokerjobindo.com/search/label/Loker%20Jurusan%20Teknologi%20Informasi
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Administrasi
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Akuntansi
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Alfamart
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Arsiparis
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Artis
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Astra
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Asuransi
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Auditor
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20BJB
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20BNI%20Syariah
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20BRI
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20Danamon
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20Mandiri
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20Indonesia
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20BCA
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20BTN
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20CIMB%20NIAGA

  4. jim says:

    hai, I just want to tell you that I am just very new to blogs and seriously loved this website. More than likely I’m planning to bookmark your blog post .
    You amazingly come with really good posts. Thanks a lot for sharing your blog Microsoft.

    http://www.lokerjobindo.com/search/label/Loker%20Jurusan%20Akunting
    http://www.lokerjobindo.com/search/label/Loker%20Jurusan%20Asuransi
    http://www.lokerjobindo.com/search/label/Loker%20Jurusan%20Teknologi%20Informasi
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Administrasi
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Akuntansi
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Alfamart
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Arsiparis
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Artis
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Astra
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Asuransi
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Auditor
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20BJB
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20BNI%20Syariah
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20BRI
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20Danamon
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20Mandiri
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20Indonesia
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20BCA
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20BTN
    http://www.lokerjobindo.com/search/label/Lowongan%20Kerja%20Bank%20CIMB%20NIAGA

Comments are closed.