Extracting Useful Info About Your Computer Using WMI

There is a whole lot one could write about WMI (Windows Management Instrumentation).  Let’s just say that there is a seemingly endless supply of information available about your computer via WMI.  Here are just a few samples using the extremely useful Get-WMIObject cmdlet.
Curious about which BIOS version your computer uses?  Try this:
PS> get-WMIObject Win32_Bios
Manufacturer      : Dell Computer Corporation
Name              : Phoenix ROM BIOS PLUS Version 1.10 A07
SerialNumber      : 40X6W31
Version           : DELL   – 8
How about information on your CPU?
PS> get-WMIObject Win32_Processor
AddressWidth                : 32
Architecture                : 0
Availability                : 3
Caption                     : x86 Family 15 Model 2 Stepping 9
ConfigManagerErrorCode      :
ConfigManagerUserConfig     :
CpuStatus                   : 1
CreationClassName           : Win32_Processor
CurrentClockSpeed           : 2992
CurrentVoltage              : 15
DataWidth                   : 32
Description                 : x86 Family 15 Model 2 Stepping 9
DeviceID                    : CPU0
ErrorCleared                :
ErrorDescription            :
ExtClock                    : 800
Family                      : 2
InstallDate                 :
L2CacheSize                 : 0
L2CacheSpeed                :
LastErrorCode               :
Level                       : 15
LoadPercentage              : 4
Manufacturer                : GenuineIntel
MaxClockSpeed               : 2992
Name                        :               Intel(R) Pentium(R) 4 CPU 3.00GHz
ProcessorId                 : BFEBFBFF00000F29
Ever wondered how much cache memory your processor has? 
PS> get-WMIObject Win32_CacheMemory |
>> select DeviceID,@{e={($_.BlockSize*$_.NumberOfBlocks)/1K};n="SizeKB"} |
>> format-table -auto
DeviceID       SizeKB
——–       ——-
Cache Memory 0       8
Cache Memory 1     512
How do you like that @{} hashtable I used in "select" above?  The Select-Object cmdlet allows you to not only project properties from the incoming object onto a new object.  It also allows you to create a "computed" property and name it.  In this case, I compute the cache size in KB from the two properties BlockSize and NumberOfBlocks and name the new property "SizeKB".
How about main memory?  Say you want to order more memory for your PC but you can’t remember if the 512 MB you have is provided by a single 512 MB DIMM or by two 256 MB DIMMs or perhaps by four 128 MB DIMMs.  Try this to find out your configuration without having to crack the case:
PS> get-WMIObject Win32_PhysicalMemory |
>>   select DeviceLocator, Capacity, Speed | sort DeviceLocator | ft -auto
DeviceLocator      Capacity Speed
————-      ——– —–
CHANNEL A DIMM 0  536870912   400
CHANNEL A DIMM 1  536870912   400
CHANNEL B DIMM 0 1073741824   400
Or perhaps you need information about your hard drives:
PS> get-WMIObject Win32_DiskDrive
Partitions : 3
DeviceID   :
Model      : ST3120026AS
Size       : 119998609920
Caption    : ST3120026AS
Partitions : 1
DeviceID   :
Model      : WDC WD1600JS-00MHB0
Size       : 160039272960
Caption    : WDC WD1600JS-00MHB0
This is just an inkling of what information is available from WMI.  There are 513 Win32_ WMI classes on my XP system:
PS> get-WMIObject -list | select __class | where {$_ -match "Win32"} |
>>   Measure-Object
Count    : 513
Check out MoW’s blog for more information on how you can make WMI really sing from PowerShell.
This entry was posted in PowerShell. Bookmark the permalink.

One Response to Extracting Useful Info About Your Computer Using WMI

  1. dicconb says:

    Thanks very much for this post. The section on how to list RAM DIMMs and their sizes will save me a lot of time!

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s