Common hardware WMI queries

Hardware Asset Tag

1 root\cimv2
2 SELECT * FROM Win32_SystemEnclosure
3 SMBIOSAssetTag

Computer Manufacturer

1 root\cimv2
2 SELECT * FROM Win32_ComputerSystem
3 Manufacturer

Computer Model

1 root\cimv2
2 SELECT * FROM Win32_ComputerSystem
3 Model

Computer Serial

1 root\cimv2
2 SELECT * FROM Win32_BIOS
3 SerialNumber

Chassis Type

1 root\cimv2
2 SELECT * FROM Win32_SystemEnclosure
3 ChassisTypes
Note: I use the chassis type field to determine the whether it is a a mobile device (laptop or tablet) or a desktop. There is a problem at times because it is up to the OEM to determine the correct setting, and sometimes they get it wrong. Here are the codes that work most of the time.
8 = Tablet
9 = Laptop
10 = Laptop
11 = Laptop
14 = Laptop
Everything Else = Desktop or Server
On the odd occasion, I need to override the above for certain models, like the Dell XPS which is given an 8 for tablet event though its an Ultrabook laptop.
More info
 
 

How to use the WMI query?

There are many ways to utilise WMI, below are just a couple of examples on how to do this:

VBScript

Here is a quick snippet of where I use a WMI query to retrieve the Manufacturer and Model for the current machine using VB Script:

1 ' Sets computer name to the current computer name
2 strComputer = "."
3 ' Connect to the WMI Service
4 Set objWMIService = GetObject("winmgmts:" "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
5 ' Fetch all details from Win32_computersystem
6 Set colComputerSystem = objWMIService.ExecQuery ("Select * from Win32_computersystem")
7 Set colBIOS = objWMIService.ExecQuery ("Select * from Win32_BIOS")
8 ' Look through all values, and make variables for manufacturer and model
9 For each objComputerSystem in colComputerSystem
10     GetComputerManufacturer = objComputerSystem.Manufacturer
11     GetComputerModel = objComputerSystem.Model
12 Next
13 Wscript.echo "The system you are on is a " & GetComputerManufacturer & " " & GetComputerModel

Simply save the above code as a .vbs file and execute it on a machine to see the results.

More detailed information can be found here on that particular script:
http://ivan.dretvic.com/2012/10/automatically-generate-description-field-for-computers-in-active-directory/

PowerShell

In a PowerShell window run the following command to extract the Manufacturer and Model of the hardware on the local machine:

1 Get-WmiObject win32_computersystem | Select Manufacturer,Model

and the output can be seen here:

PS - WMI Manufacturer Model
As you can see once its in PowerShell the capabilities to manipulate and format the data is quite easy.