r/SCCM•
MrsVague

Task Sequence WMI Query for Laptop/Desktop

In MDT I can use 'IsLaptop' and 'IsDesktop' which great but those variables don't exist in SCCM.

I've been struggling with the syntax getting my WQL search in the task sequence for querying laptops and desktops.

​

Anyone else able to get that to work?

Posted Oct 29, 2019, 1:50 AM UTC

617
phiish•

Why not mdt integrate sccm so you can use all of those variables ?

7
Jhanno•

You should do this. J do it in all my environments and have yet to find any good reason not to

2
MrsVagueOP•

I don't manage the SCCM Site Server. I have access to the console and the Distribution Point in my area but that's it. Also seems like a heavy solution just to gain access to those variables.

1
phiish•

MDT integration is not a big deal by any means especially considering the flexibility you gain.

1
NoDowt_Jay•

Been using this in my TS WMI querys for years without issue...

Laptop: SELECT * FROM Win32_ComputerSystem WHERE PCSystemType = "2"

Anything else: SELECT * FROM Win32_ComputerSystem WHERE PCSystemType != "2"

5
MrsVagueOP•

Perfect. This is exactly what I'm looking for. Thanks!

2
taylorblakeharris•

I'll be honest with you, I've found very little reason to use MDT anymore, as I've found ways to automate all aftermarket customization and software to the Windows OS.

As someone else mentioned, I'd use the PCSystemType property for your WMI query to determine if the machine is a laptop:

SELECT PCSystemType FROM Win32_ComputerSystem WHERE PCSystemType = 2

The above represents a condition in which the machine is a laptop/tablet (like a Surface Pro). If the machine is any other type, the condition will evaluate to false (or empty) and not run.

If you end up needing any additional determination for different model types other than desktops/laptops, I would create a simple PowerShell script that you execute at the beginning of the task sequence which sets a variable for you to identify the system type using the PCSystemType codes from Microsoft (reference here: https://docs.microsoft.com/en-us/dotnet/api/microsoft.powershell.commands.pcsystemtype?view=powershellsdk-1.1.0 )

This is how I would do it:

# Connect to the currently running task sequence
$tsEnv = New-Object -ComObject Microsoft.SMS.TSEnvironment

# Instantiate the Win32_ComputerSystem class
$computerSystem = Get-CimInstance -ClassName Win32_ComputerSystem

# Return description of the current system type and store in task sequence variable named 'SystemType'
$tsEnv.Value('SystemType') =
    switch ($computerSystem.PCSystemType)
    {
        0  {"Unspecified"}
        1  {"Desktop"}
        2  {"Mobile"}
        3  {"Workstation"}
        4  {"EnterpriseServer"}
        5  {"SOHOServer"}
        6  {"AppliancePC"}
        7  {"PerformanceServer"}
        8  {"Maximum"}

        default  {"Unknown"}
    }

If you save the above into a .PS1 file inside of a package, then you can call it with the "Run PowerShell Script" step in your task sequence at the very beginning. From then on, you'll have a task sequence variable you can reference in other task sequence steps or conditions called 'SystemTypeDescription'. If you just need to know if it's a laptop or not though, this is overkill and you would be better served sticking with the initial WMI query.

3
adampskib•

Integrating MDT just for variables is a poor reason. If however others said they wanted a user driven installation, then I'd somewhat accept it. Even then, it's a dead product with minimal support and development, I'd always be in favour of avoiding it like the plague.

3
Bigw25MSFT Official•

Chassistype, but with 23 (I think) chassis types, you have to map each to the appropriate form factor.

2
Wogdog•

I think with older machines this was definitely the case. I have found that manufacturers have gotten better with hitting the correct type, at least the vendors we use (HP/Lenovo).

1
Elderfin•

I have a child task sequence that I set up that installs the drivers. I will try to attach screenshots. You can see from the first screen the set up for each model. The second is an example of the query for one of the models.

The query that I used for one model is:

SELECT * FROM Win32_ComputerSystem WHERE model LIKE "%7490%"

1
MikePohatu•

The IsLaptop and IsDesktop stuff usually comes from ChassisTypes in Win32_SystemEnclosure. Have a look at the source code here for examples of which class goes into which classification e.g. ChassisType 8, 9, 10, 11, 12, 14, 18, 21, 30, 31, and 32 are laptops (or at least I classified them as laptops): https://github.com/MikePohatu/TsGui/blob/master/TsGui/Control/HardwareEvaluator.cs

It's C# but it's pretty easy to follow what it's doing even if you don't know that particular language. Just look at the case statements. WQL would probably end up something like:

select ChassisTypes from Win32_SystemEnclosure WHERE ChassisTypes = 8 OR ChassisType = 9.....

Full listing of the chassis types is linked in the top of the source file

1
MattWorksSCCM•

Ditto...
and if it isnt one of these variables, then handle that as well..

1
mjs2425•

I was facing a similar issue along with a desire for a more GUI interface during osd. I ended up using tsgui. It will set the variables automatically along with full custom support.

1
jddf889•

I use the battery class where description is like internal.

-1
Kenifyable•

Avoid using battery queries. Use chassis type wherever you can. Battery queries are doomed for failure once battery is dead and BIOS do not recognize it as being inserted anymore.

2
rjchau•

On top of that, quite a number of UPS software packages will install a battery device as well.

2