Where Is the Where?
To more easily modify the Where clause in a script, substitute the Where clause with a variable. This configuration can be modified to include command-line input as well. This is shown in the ListSpecificWhere.ps1 script.
ListSpecificWhere.ps1
$strComputer = "."
$wmiNS = "root\cimv2"
$strWhere = "'ipc$'"
$wmiQuery = "Select * from win32_Share where name="+$strWhere
"Properties of Share named: " + $strWhere
$objWMIServices = Get-WmiObject -computer $strComputer `
-namespace $wmiNS -query $wmiQuery
$objWMIServices |
Format-List -property [a-z]*
Quick Check
Q. | To limit the specific data returned by a query, what WQL technique can be utilized? |
A. | The Where clause of the WMIquery argument is very powerful in limiting the specific data ... |
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.