Handling Chassis Types In SCCM OSD

Posted on Updated on

One of the challenges with condensing workstation task sequences into a single task sequence is being able to distinguish between desktops and laptops as each typically has their own set of functions to perform when being imaged.  One of the best ways to determine this is by querying ChassisTypes in Win32_SystemEnclosure.  Unfortunately, ChassisTypes is an array value; the WQL that is used in the task sequence is limited to single values.

To work with this, add the following vbscript to a Run Command Line task.  It creates a custom Task Sequence variable that can then be used to dynamically limit certain tasks to “desktops” and others to “laptops”.

' NAME: SMSTSEnvChassisType.vbs
' AUTHOR: Nick Moseley, SCCM Administrator
' DATE  : 4/24/2009
' COMMENT: Script creates custom TS variable that can be used to distinguish
' between a desktop and a laptop for dynamically selecting which tasks
' to run in the sequence. Note that the echo statements are logged in SMSTS.log
Dim oTaskSequence, oWMI, colChassis, sChassisType, oChassis
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironment")
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colChassis = oWMI.ExecQuery("Select * from Win32_SystemEnclosure")
For Each oChassis in colChassis
For  Each sChassisType in oChassis.ChassisTypes
  Select Case sChassisType
      Case 8
                Wscript.Echo "Chassis Type: Portable"
                oTaskSequence ("OSDImageType") = "laptop"
            Case 9
                Wscript.Echo "Chassis Type: Laptop"
                oTaskSequence ("OSDImageType") = "laptop"
            Case 10
                Wscript.Echo "Chassis Type: Notebook"
                oTaskSequence ("OSDImageType") = "laptop"
            Case 12
                Wscript.Echo "Chassis Type: Docking Station"
                oTaskSequence ("OSDImageType") = "laptop"
            Case Else
                Wscript.Echo "Chassis Type: Unknown"
                oTaskSequence ("OSDImageType") = "desktop"
  End Select

12 thoughts on “Handling Chassis Types In SCCM OSD

    Maarten said:
    May 5, 2009 at 5:07 am


    I’m trying to get this script implemented in one of my tasksequences but it keeps failing. Are you sure this is working? Tried pretty much everthing I can think of but unfortunately I’m no script guru so not really my place to argue ;)

    I thought that maybe because you declare oTSEnvironment to contaign the TS variables (or that is what I think anyway) and then set the OSDImageType variable using oTaskSequence instead of oTSEnvironment?

    any ideas?
    thanks for your help

    Nicolas Moseley responded:
    May 5, 2009 at 6:58 am

    Maarten – thanks for the advising me! Sorry about the confusion, I had pasted some old code. Plus I found that a copy/paste of the text messed up some of the characters. I’ve updated the code and changed the font. It should work now, but let me know if you continue to have issues.

    Umesh said:
    June 15, 2009 at 11:08 pm

    Hi Nicolas,

    I ma facing one strange issue with task sequence.

    I have one captured image which use for OS deployment.

    The task sequence was running perfectly till last week.
    Now all of a sudden same task sequence with same settings is not working on same system on which it was running without issue.

    After system reboots in a Win PE , it initialize the hardware and shows ” Windows is starting” message. After that it does nor proceed and does not show any thing except background image and system reboots after couple of minutes.

    Please Help.


    Nicolas Moseley responded:
    June 16, 2009 at 5:54 am

    Thanks for the comment Umesh,

    The problem you’re experiencing sounds like the disk drivers are not initiating or the disk is not being found within WinPE, so the system just restarts. Instead of using this blog as a location for troubleshooting further, I would like to invite you to post on MyITForum or on the Microsoft SCCM Forums as there are many people who can help you resolve this problem. You can find links on the left under “Forums”. I look forward to you joining the community!

    p.s. Though Nicolas is my full name, I really only force my family to call me by my full name. You’re welcome to call me Nick :-) Unless you really really want to call me Nicolas, then that’ll work too…

      Killragtshirts said:
      October 20, 2009 at 5:51 am


      I use a custom TS variable script to grab chassis type and default gateway of the machine. However, the default gateway script does not seem to work in a TS environment. I know this because TS steps later in the build process don’t work when I have a default gateway variable assigned to the step. I noticed that you mention that the Echo statements are logged in SMSTS.Log….Is that writing to the log each time its processing the Echo statements? Im just trying to work out if I could do a similiar thing in my script to troubleshoot the process.


        Nicolas Moseley responded:
        October 20, 2009 at 6:42 am

        Yep – every echo statement in the vbscript will appear in SMSTS.log – it is very useful for troubleshooting.

    Richard said:
    September 10, 2012 at 10:47 am

    Hi Nick,
    I am using your SMSTSEnvChassisType.vbs via my SCCM 2007 – OSD Task Sequence, however I am getting the following when it runs – “\Laptop_Check\TSSysEnclosure.vbs(10, 1) (null): The specified module could not be found.” Any ideas to what is not working properly?

      N. Moseley responded:
      September 10, 2012 at 8:39 pm

      Line 10 is where the task sequence object is created. Sounds like your task sequence is not actively running when you execute the script.

    Trinity Rolling said:
    November 13, 2012 at 10:56 am

    Nick, if I were to use your script in a task sequence and call it using a command line step. Lets say my next step is to create a computer name. I want to utilize the Chassis Type. How would I call this in my Computer Name script? Would I use OSDImageType as shown below?

    strName = “TPC-” & OSDImageType & strSerial

    Awesome scripts btw! Always good information. Well written and a great presentation. I’ll stop stroking your ego now. Thanks!

      Trinity Rolling said:
      November 13, 2012 at 11:25 am

      Answered my own question.
      Set objSMSEnv = CreateObject(“Microsoft.SMS.TSEnvironment”)
      strChassis = objSMSEnv(“OSDImageType”)
      strName = “TPC-” & strChassis & strSerial

        N. Moseley responded:
        November 13, 2012 at 11:28 am

        Great! Glad you were able to figure it out. Sorry, I didn’t have a chance to look at your question in detail yet….it’s that whole day job thing ;-)

    OSDComputerName – Methods said:
    November 13, 2012 at 3:09 pm

    […] into your Computer Name.  I use many forms of his scripts with minor changes.  Take a look at his Chassis Script to return chassis type as a Task Sequence Variable. The script below requires the use of […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s