In this article I will show you how to query wmi to get the computer model and vendor which you can use in SCCM.
Better yet I have written a powershell script you can copy and paste which will retrieve your hardware vendor and model for you.
I will also list the most common WMI queries used so you can just copy and paste them as well.
How To Query WMI To Get Computer Model
The easiest way to get the computer model via wmi is with powershell, To do that follow these steps
- Open powershell ise
- Copy the below code and paste it in to powershell
$Computerinfo = Get-WmiObject win32_computersystemproduct
$Vendor = ‘Computer Vendor = ‘ + $computerinfo.Vendor
$Model = ‘Computer Make = ‘ + $computerinfo.Versioncls
Write-Host””
$Vendor
$Model
Write-Host”” - Click run
- The computer vender and model will be displayed in the result
Above we can see I ran this query on my laptop and my vendor is LENOVO and my computer model is ThinkPad T14s Gen 1
We can now use this information to form a WMI query that we can use in SCCM.
Below is an example of a query I used in a task sequence to only apply the step to a HP Z2 G5 machine
How To Create A WMI Query To Use In SCCM
Now we have the Vendor and Model of the hardware we can now create a WMI query that we can use in SCCM.
In the above example I got the below result from my query
- Vendor is LENOVO
- Model is ThinkPad T14s Gen 1
So the query for my vendor will be SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE “%LENOVO%”
And the query for my model will be SELECT * FROM Win32_ComputerSystem WHERE Model LIKE “%ThinkPad T14s Gen 1%”
You will obviously need to replace the vendor and model with the result you get from running the above script.
Examples Of WMI Queries
Listed below are some of the most common queries that you can use
HP
- Vendor = HP | SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE “%Hewlett-Packard%”
- Model = HP EliteBook 840 G5 | SELECT * FROM Win32_ComputerSystem WHERE Model LIKE “%EliteBook 840 G5%”
- Model = HP Pavilion x360 | SELECT * FROM Win32_ComputerSystem WHERE Model LIKE “%Pavilion x360%”
Lenovo
- Vendor = Lenovo | SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE “%Lenovo%”
- Model = Lenovo Thinkpad x1 Carbon Gen 11 | SELECT * FROM Win32_ComputerSystem WHERE Model LIKE “%Thinkpad x1 Carbon Gen 11%”
- Model = Lenovo Yoga Book 9i | SELECT * FROM Win32_ComputerSystem WHERE Model LIKE “%Lenovo Yoga Book 9i%”
Dell
- Vendor = HP | SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE “%Dell%”
- Model = Dell Lattitude 5500 | SELECT * FROM Win32_ComputerSystem WHERE Model LIKE “%Lattitude 5500%”
- Model = Dell Venue 11 Pro 7130 | SELECT * FROM Win32_ComputerSystem WHERE Model LIKE “%Dell Venue 11 Pro 7130%”
Where Can You Use WMI Queries In SCCM
There are many sections within SCCM that you can use wmi queries, they are commonly used in
- Task Sequences : To limit a task sequence step to only run on certain hardware to install drivers or applications
- Device Collections : To only show machines on a certain hardware vendor / model
- Reports : To report on certail hardware vendors / models
- Queries : Same as reports