How to use it

  1. Pick a condition type, a test and a value.
  2. Press Add a condition for each extra condition.
  3. Choose if a device must match all conditions or any condition.
  4. Press Copy query.

Where to paste the query

  1. Open the Configuration Manager console and go to Assets and Compliance, then Device Collections.
  2. Open the properties of your collection and select the Membership Rules tab.
  3. Press Add Rule and pick Query Rule.
  4. Type a name for the rule and press Edit Query Statement.
  5. Press Show Query Language.
  6. Delete the text in the box, paste your query and press OK.

Then update the collection membership and check the member count.

What the query looks like

A collection query is written in WQL, the WMI Query Language. Every query starts with the same list of SMS_R_System properties. The tool keeps that list as the console writes it.

Some conditions use discovery data. Computer name, OU, security group, IP subnet and client version are all in SMS_R_System. These need no join.

Other conditions use hardware inventory. Operating system, manufacturer, model, chassis type, disk space and the last inventory date are in SMS_G_System classes. The tool adds one inner join for each class it needs.

Things to know

  • Inventory conditions only match devices that have sent hardware inventory. A new client can take a day to show up.
  • The application conditions read the Programs and Features list. They check both the 32-bit list and the 64-bit list.
  • "Application NOT installed" uses the ResourceId not in pattern. Add "client is installed" too, or devices with no client will match.
  • The OU test also matches devices in child OUs. Discovery stores every level of the OU path for each device.
  • Write a security group as DOMAIN\Group. The tool doubles the backslash, as WQL needs.
  • The build number and the client version are stored as text. The comparison works when both values have the same number of digits.
  • Free space is stored in MB. The tool converts your GB value.

Questions

Why does my collection show zero members?

First update the collection membership and wait for the hourglass to clear. Then check that the devices have sent hardware inventory. Last, check the value. A test such as "is exactly" must match the full text that inventory holds.

Can I mix AND and OR in one query?

This tool joins all conditions with one word. For a mix, build each part here and join the parts by hand with brackets. You can also add two query rules to one collection. A device that matches any rule becomes a member.

Do the % and _ characters mean something special?

Yes, in a "like" test. The % sign stands for any text. The _ sign stands for any one character. So LAP-% matches every name that starts with LAP-.