23.2. Using the get-wmiobject Cmdlet

The get-wmiobject cmdlet is the single cmdlet in PowerShell version 1.0 to allow you to retrieve WMI-based information. There is no comparable set-wmiobject cmdlet, at least not in PowerShell version 1.0.

NOTE

Using WMI or the get-wmiobject cmdlet to access information from a local or remote computer makes the assumption that you have appropriate privileges to carry out the required tasks. WMI also needs to be installed on the target computer.

To display the definition of the get-wmiobject cmdlet, use the following command:

(get-command get-wmiobject).definition

As you can see in Figure 23-5, there are essentially two overloads for the get-wmiobject cmdlet. If you use the class parameter, you are selecting a WMI class (or classes) on a specified machine and then displaying properties or manipulating those properties in some way. If you use the list parameter, you are exploring what classes are present in a specified namespace. Broadly, these approaches correspond to what you can do with the WMI Object Browser and CIM Studio, respectively.

Figure 23.5. Figure 23-5

In addition to the common parameters, the get-wmiobject supports the following parameters.

  • Class — Specifies a WMI class whose properties are of interest. This is a required parameter. It is a positional parameter in position 1. Wildcards are not allowed. If the List parameter is ...

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.