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 ...
Get Microsoft® Windows PowerShell™ Step By Step 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.