Technology Support Center

Administrative Technologies

Using Query Collection Membership Rules in SCCM 2012

This article gives examples for using the Query collection membership rule in SCCM 2012.

Before you begin

If you have not already done so, read 1880: Understanding collections in SCCM 2012 before continuing.

Reasons for using query membership rules

Reasons for using query membership rules could include the following:

  • You want to create a collection that contains all computers currently using Windows 7.
  • You want to create a collection based a resources location in the Active Directory OU structure.
  • You would like to create a collection of all computers that have a computer name that ends in "laptop."

​Steps for using query membership rules

Adding resources using a query rule when creating a new collection

Follow the instructions outlined in 1884: Creating a collection in SCCM 2012. When you reach step 7 select Query Rule and do the following:

  1. Type the name you want to save the query rule as in the Name: dialog box.
  2. Click the Edit query Statement... button
  3. Under the General tab, click the yellow star button to add an attribute you would like to include in the query. The result properties window will open.
  4. Click the Select... button and choose the Attribute class you would like to use.
    Important: Attribute classes can be thought of as categories for different types of attributes. Generally, you will want to select either System Resource, User Resource, or User Group Resource.
  5. Click the Attribute drop-down box and select the attribute you want to include in the query and click OK.
  6. Click OK to close the Result Properties window.
  7. Repeat steps 3-6 to add any additional attributes you would like to include in the query.
  8. Click the Criteria tab.
  9. Click the yellow star button to add a new criteria. Criteria is used to narrow the results of query.
  10. Select your Criterion Type from the dropdown menu. Generally you will want to select Simple value.
  11. Click the Select... button and choose the Attribute class and Attribute you would like to narrow your query by and click OK.
  12. Select the Operator you would like to use to narrow your query by.
  13. Click the Value... button. The values window will open showing all available values SCCM is aware of for the attribute you selected. Select the attribute you would like to use to narrow your query results and click Ok.
  14. Click Ok to close the Criterion Properties
  15. Repeat steps 8-14 to add any additional criteria to narrow your query results.
    Important: After adding additional criteria you can toggle the operators of the criteria by clicking the default "and" operator in the list of  the criteria you have added and click the "&|" button above the list.
  16. Click Ok to close the Query Statement Properties window.
  17. Click Ok to close the Query Statement Properties window.
  18. Click Ok to close the Query Rule Properties Window.
  19. Check the "Use incremental updates for this colection" checkbox.
  20. Note the default schedule that a full update of the membership of the collection is re-evaluated. To make a change click the Schedule... button. Click Next.
    Important: To reduce unnecessary server load, refrain from creating a full update schedule more frequently than once a day.
  21. Review your settings and click Next.
  22. Click close.

It may take a few minute for the new collection to populate it's members for the first time. When membership is being evaluated the icon for the collection will have an hour glass next to it when viewed in the SCCM 2012 Management console.

Important: The items in the collection list do not automatically refresh. To refresh the status of a collection, click it and press F5. When the collection has finished updating its membership the hourglass icon will be disappear.

Specific Example: Creating a new collection with query rules to add resources based on their location in the Active Directory OU structure.

The following instructions show an example of creating a new collection that adds members to it based on what OU the computer account resides in active directory. Follow the instructions outlined in 1884: Creating a collection in SCCM 2012. When you reach step 7 select Query Rule and do the following:

  1. Launch the SCCM 2012 manager Console.
  2. In the Assests and Compliance workspace on the left-hand portion of the screen, right-click Device Collections and click Create Device Collection.
  3. In the Name: dialog box type the name you would like the new collection to have.
    Important: Always preface the name of a collection with your IT support areas department acronym. For example, CIS Walkups.
  4. In the comment: dialog box type a brief description of the collection.
  5. Click the browse.. button and selection your IT areas master device collection, for example CIS Master Device Collection and click OK.
  6. Click Next.
  7. Click the Add Rule drop-down menu and select Query Rule.
  8. Type the name you want to save the query rule as in the Name: dialog box.
  9. Select System Resource from the Resource class: dropdown menu.
  10. Click the Edit query Statement... button
  11. Under the General tab, click the yellow star button. The result properties window will open.
  12. Click the Select... button.
  13. Select System Resource from the Attribute class dropdown menu.
  14. Select System OU Name from the Attribute dropdown menu and click OK.
  15. Click OK to close the Result Properties window.
  16. Click the Criteria tab.
  17. Click the yellow star button to add a new criteria.
  18. Select Simple value from the Criterion Type: dropdown menu.
  19. Click the Select... button, the Select Attribute window will open.
  20. Select System Resource from the Atrribute class dropdown menu.
  21. Select System OU Name from the Attribute dropdown menu and click OK.
  22. Select "is like" from the Operator dropdown menu.
  23. Click the Value... button. The values window will open.
  24. Select an OU from the list, for example AD.ILSTU.EDU/CISS/WALKUPS, and click OK.
    Important: Only OUs being discovered by SCCM for your IT area will be listed.
  25. Click Ok to close the Criterion Properties window.
  26. Click Ok to close the Query Statement Properties window.
  27. Click Ok to close the Query Rule Properties Window.
  28. Check the "Use incremental updates for this colection" checkbox.
  29. Click the Schedule... button.
  30. Choose a start date as the current date.
  31. Set the start time to 12:00 AM.
  32. In the Recurrence pattern section, select "Custom interval."
  33. Under "Recur every:" set the value to "1 Days" and click OK.
  34. Click Next.
  35. Review your settings and click Next.
  36. Click close.

You will now have created a collection that adds all computer accounts for the OU you selected and any sub-OUs it may contain as long as those computers are also members of the limiting collection you chose. This collection will check for incremental changes for computer accounts that have been added or removed from those OUs every 15 minutes.It will also perform a full re-evaluation of those OUs every night at 12:00 AM.