One of the conditions that can be used is a WQL query.
This post explains what WQL is and how to use it.
What is WQL
WQL stands for "WMI Query language"
WQL is a subset of SQL and can be thought of as "SQL for WMI"
Why use it?
Having the ability to run a task based on a WQL query is incredibly powerfull.
This means you can cause something to happen (or not happen) based on the result of a WMI property.
e.g
You may want to run a driver package only on specific types of hardare
Whilst a common scenario, it's not "obvious" how to create and test a WQL query when starting from scratch.
Creating and testing with WQL
The Task sequence editor dosn't provide any help with constructing or testing a WQL query, so (to avoid pain and dissapintment!) it's best to TEST this using another tool before using a WQL query in a task sequence.
An easy way to do this is to use WBEMTest.exe
Using "Windows Management Instrumentation Tester" (WBEMTest) to validate a WQL query
- run WBEMTest.exe
- Select "Connect..."
- Enter root\cimv2 (instead of root\default)
- Select Connect
- Select "Query..."
- Start by entering a simple query
e.g. SELECT * FROM Win32_Computersystem - Select "Apply" to run the query
- You'll see a "Result" similar to the one below:
- Double-click on the result to "drill-down" and have a look for some more "interesting" properties to query for!
- Scroll-down within "Properties" and note the value for "Model"
(in my example this is a "ProLiant ML110 G5")
- You can use these details to construct a more useful WQL query.
- Go back to the query screen (Close,Close then Query)
- Enter a query using the new values:
SELECT * FROM Win32_ComputerSystem WHERE Model = "your model"
- In my case this returns "1 objects". This means it's a "success"
(i.e. will be evaluated as "True" if used within a Task Sequence)
What happens if a query dosn't evalue to True
- Below is the output when looking for something that won't result in a match
- Basically it returns "0 objects"
(i.e. will be evaluated as "False" if used in a Task Sequence")
What happens if an invalid query is specified
This is likely to be a common scenario when "getting the hang of it" / testing.
Other Queries to try
Show all local accounts
- SELECT * FROM Win32_Account
This can be easily "refined" to look for a specific account
- SELECT * FROM Win32_Account WHERE Name = "FredBloggs"
Useful References
No comments:
Post a Comment