Common WMI queries I have found useful

Below are some common WMI Queries that I have used, both during OSD (Operating System Deployment), startup/logon scripts or similar situations. I have broken them down to their most common form, and will show you how you can leverage this in a VB script at the end.

I will continue to update this post with new useful queries that I come across.

Common hardware WMI queries

Hardware Asset Tag

 

Computer Manufacturer

Computer Model

Computer Serial

Chassis Type

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:

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:
https://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:

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.

6 thoughts on “Common WMI queries I have found useful”

    • Thanks, its a post I have not updated in quite some time.
      With PowerShell being available on most servers and clients these days its become my preferred scripting language due to its power.

      Thanks for sharing – I will update my list to include more in the coming months.

      Reply

Leave a Reply to CypherBitCancel reply

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

QR Code Business Card