Task Sequence Variables

Update 2018.12.24 – Johan Schrewelius has updated the gather.ps1 script on Technet .He has added several more variables, including the ones I was still needing to completely move away from MDT.  I’ve updated the screen captures to included the additional variables.

—-

Recently at MMS Desert Edition, I was talking with Jörgen Nilsson (ccmexec.com) and he said they had posted a PowerShell replacement for the MDT Gather step.  I spent the next hour searching for it, just to find it hadn’t been posted.. Jörgen & Johan Schrewelius just thought they had posted it. They quickly posted it after they realized it wasn’t posted.. and now we can all benefit!

So here is the link to the download:

https://gallery.technet.microsoft.com/PowerShell-script-that-a8a7bdd8

Basic documentation is included.

To continue on, variables, they are very important in your TS, they allow tons of flexibility.  Built into your standard ConfigMgr TS, there are already quite a few, most are documented HERE

By running a single step (Set Dynamic Variables), you’ll automatically get several more variables, a couple examples are:
_SMSTSDefaultGateways, _SMSTSIPAddresses, _SMSTSMake, _SMSTSModel

Then by running the Gather PowerShell script, you’ll get several more, including, but not limited to: IPAddress, IsDesktop, IsLaptop, IsServer, IsVM, SerialNumber, BIOSVersion

How to get your variables in a log file?  Well, Johan also posted a nifty script to dump the variables, blogged by Jörgen Here: https://ccmexec.com/2016/11/dump-task-sequence-variables-during-osd-the-safe-way/

Using that method, I created a test that dumped the variables 3 times,  one after running “Set Dynamic Variables”, and one after running the gather script, and one with MDT Gather: (I got the idea from Mike Terrill who did something similar during his MMS session.)

My Set Dynamic Variables Step also included 3 variables I set manually in my TS:
image

Technet GatherScript Step:
image

Safedump Step: (Dumping variables to log file)
image

I then used WinMerge (Portable x64) in WinPE to load the 3 dumps and compare:
image

Results: (Left = TS after Dynamic Variable Step, Middle = Technet Powershell Gather Script, Right = MDT Gather)

image

image

As you can see, there are still several variables that integrating MDT will give you, so if you find any value in these , you’ll still need to integrate MDT (or not, keep reading below to learn more) and use the MDT Gather Step.  You can see some of the variables below that you get with MDT. (Left = Default, 140 variables,  Right = MDT Gather, 192 variables.)

image

image

To get the MDT variables, you don’t have to actually integrate MDT, there is a nifty trick to just grab a few files from MDT and create your own package.  Gerry blogged about it here. http://gerryhampsoncm.blogspot.com/2017/03/configmgr-osd-use-mdt-without-using-mdt.html

I had switched to MDT Lite, but Johan continued to update his TechNet script, so it now has everything I need, so I’ve switched to using that and no longer using MDT for variables.

Download this test Task Sequence HERE Does NOT included updated TechNet Script.

Thanks to:

Posted on GARYTOWN.COM

2 thoughts on “Task Sequence Variables”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.