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 image from book ListSpecificWhere.ps1 script.

image from book 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]*

image from book
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 returned by a query.

Q. What are three possible operators that can be employed in creating powerful Where clauses?

A. The equals sign (=) and the greater than (>) and the less than (<) symbols can be used to evaluate the data before returning the dataset.

image from book




Microsoft Press - Microsoft Windows PowerShell Step by Step
MicrosoftВ® Windows PowerShell(TM) Step By Step (Step By Step (Microsoft))
ISBN: 0735623953
EAN: 2147483647
Year: 2007
Pages: 128
Authors: Ed Wilson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net