Querying WMI
In most situations, when you use WMI, you are performing some sort of query. Even when you're going to set a particular property, you still need to execute a query to return a dataset that enables you to perform the configuration. (A dataset includes the data that come back to you as the result of a query, that is, it is a set of data.) In this section, you'll look at the methods used to query WMI.
Note
Just the Steps To query WMI:
Specify the computer name.
Define the namespace.
Connect to WMI by using Get-WMIObject.
Specify the query by supplying a value for the filter argument or the query argument.
Use Format-List or another cmdlet to clean up the output.
In the QueryDesktop.ps1 script, we define three variables that are used to hold ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access