Book Image

Mastering Windows PowerShell Scripting

By : Brenton J.W. Blawat
Book Image

Mastering Windows PowerShell Scripting

By: Brenton J.W. Blawat

Overview of this book

Table of Contents (22 chapters)
Mastering Windows PowerShell Scripting
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Searching for WMI classes


There are instances when you may want to search for different WMI classes on a system. The two primary cmdlets that enable you to search WMI are get-wmiobject, and get-cimclass. You can simply leverage the get-wmiobject cmdlet with the –list argument to list all the classes in a particular namespace. You can further narrow down the list by piping the command to the statement where {$_.Name –like "*Search*"}. This will search the Name property of the classes that match a specific criterion.

An example of using the get-wmiobject cmdlet to find classes with a specific value would look like:

get-wmiobject –list | where{$_.Name –like "*Time*"}

The output of this command is shown in the following screenshot:

The preceding example displays how to properly leverage the get-wmiobject cmdlet to search for WMI classes. You first start by declaring the get-wmiobject cmdlet with the –list parameter. You then leverage where the pipeline property of Name is like the word Time. After...