23.3. Exploring a Windows System

Now that you have seen the basics of how the get-wmiobject cmdlet can be used and know how to explore the root/cimv2 namespace, I will illustrate some of the ways in which you can use the get-wmiobject cmdlet to explore the characteristics of a Windows system.

23.3.1. Characterizing the CPU

To characterize the CPU on a system, you can use the Win32_Processor class in the root\cimv2 namespace. The following command retrieves information about the processor on the local machine:

get-wmiobject Win32_Processor |
format-list Name, MaxClockSpeed, AddressWidth, Description

The first step of the pipeline uses the Win32_Processor class to find all processors on the local machine. The ComputerName parameter is not expressed. However, its default value of localhost is assumed by the PowerShell processor. The second step displays the values of the Name, MaxClockSpeed, AddressWidth, and Description properties of the object(s) passed to it by the first pipeline step.

Figure 23-13 shows the results on a machine with a dual-core Athlon processor. Notice that the properties of each processor are reported separately. Notice, too, the disparity between the numerics displayed in the CPU's name and the value of the MaxClockSpeed property.

Figure 23.13. Figure 23-13

23.3.2. Finding Memory

One of the advantages of using PowerShell with WMI is that you can write scripts ...

Get Professional Windows® PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.