Filtering WMI Object Properties using PowerShell

May 12, 2006

When you use the get-wmiobject cmdlet to retrieve properties of a Windows Management Instrumentation, WMI, class you can be overwhelmed by the number of properties displayed. Among the properties displayed when you use an asterisk wildcard with the format-list cmdlet,

get-wmiobject -Class Win32_BIOS |

format-list *

are the WMI system properties which you probably don't want to see. You can use a more specific wildcard with the format-list cmdlet to filter the properties displayed.

If you want to display properties about the BIOS of your machine you might use the command but exclude the WMI system properties use this command:

get-wmiobject -Class Win32_BIOS |

format-list [a-z]*

How does this work? The first step of the pipeline uses the Win32_BIOS WMI class to pass its properties to the second step of the pipeline. The format-list cmdlet formats the output as a list, but which properties are to be displayed?

The [a-z]* is an extended wildcard. It's partly a traditional wildcard and partly like a regular expression. The [a-z] is a character class. It matches any lower case alphabetic character between a and z. The * matches zero or more characters. Taken together the wildcard means "Match any sequence of characters that begins with an alphabetic character".

You can use more focussed wilcards. To retrieve the properties beginning with s use this command:

get-wmiobject -Class Win32_BIOS |

format-list s*

The pattern s* matches any sequence of characters where the first character is s.
Technorati Profile

Advertisements

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

%d bloggers like this: