Wednesday, May 22, 2013

Creating SCCM Collection queries

Required Elements
To create a valid query, you must include the following elements. Use the General tab in the Query Properties dialog box and the General tab in the Query Statement Properties dialog box to add these elements.
• Query name (a unique name that identifies the query)
• Object type
• Attributes classes
• Attribute
Optional elements
These elements are not required for a valid query, but you can use them to refine query results. Use the Criteria tab and the Joins tab in the Query Statement Properties dialog box to add the following elements:
• Criterion types
• Logical operators
• Group parentheses
• Attribute class join
The following information will give you a better understanding how and what to use to build a query:

Criterion Properties:
Criterion Type: There are 5 different criterion values available to build a query. Criterion types identify the form that query expressions will take and enable you to narrow the results of a query by reducing the number of results that are returned.

For each criterion type, you are prompted to enter an About Attributes and Attribute Classes and a About Relational Operators (such as, is equal to) in addition to providing the specific information for the criterion type. You can choose from the following five criterion types.

Where:Where options provides list of attributes we can choose from. Click on Select, which opens Select Attribute window.
On attribute window,
Attribute class:
An attribute class is a container object that groups related attributes. The attributes of an object type are organized into one or more attribute classes. The attribute classes from which you can select include all the attribute classes belonging to the object type for the current query. Attribute classes are directly analogous to SQL tables and WBEM WBEM classes.
An attribute is the specific property for which the query searches. Attributes must be members of an attribute class that is associated with the object type of the current query. Attributes are directly analogous to SQL table columns and WBEM properties

Alias as: Generally, assigning an alias name is optional. However, there are some complex queries that require the use of the alias feature. When specifying an alias name for an attribute class, make sure that the new alias name is not already assigned to another attribute class. You can review the query syntax on the Joins tab to verify alias names

Attribute:
An attribute class is a container object that groups related attributes. The attributes of an object type are organized into one or more attribute classes. For each attribute class, there are list of attributes attached to it.

Operator:
AND, OR, and NOT are all valid logical operators that can be used in an Microsoft System Center Configuration Manager 2007 query. Logical operators can be used to broaden or narrow the scope of a query. Additionally, Configuration Manager 2007 evaluates expressions by using a particular operator precedence, which can affect the results.

Value:
We can choose attribute value from value tab.

Creating a Simple Collection for OS Window 7 Computers:
We will create a custom query for windows 7 machines.

Criterion Value:  Simple
Where:    System Resource – Operating System Name and Version
Operator: is equal to
Value: Microsoft Windows NT Workstation 6.1

Let’s get started:
1.       Go to System Centre Configuration Manager ->Computer Management -> Collections

2.       Right click on Collection

3.       Click on “New Collection”. This will start a “New Collection Wizard”

4.       Give a name to a collection then Click “Next”
5.       This will bring up the “membership Rules” page. On this screen we can edit the query by selecting the yellow database icon.
6.       By click the yellow icon, will open a Query rule properties page. Under the name give a Name. Then click on “Edit Query Statement”.
7.       “Edit Query Statement” will open “Query Statement Properties” as below

8.       Click on Criteria and select the yellow star to create a custom query.
9.       By clicking the Star will open the Criterion Properties window where you can choose various attributes and attribute classes from the list

10.   On Criterion Properites window choose ;
Criterion Type: Simple value (As above)
Where
Attribute class: System Resource
Alias as: <No Alias>
Attribute: System Resource - Operating System Name and Version


Then Click OK.
11.   On the Criterion Properties window choose ;
Operator: is equal to


Value: Microsoft Windows NT Workstation 6.1

12.   Completed Criterion Properties window will looks similar to below
13.   Based on your requirements, we can limit the query to one specific collection or No Collection Limited, then click Ok







14.   That will close the query wizard and brings back to the ‘New Collection Wizard’. 15. From here accept all the default values.




15.   From here accept all the default values and complete the wizard.
16.   Now, the newly created collection should appear under the collection. If you refresh the Windows 7 collection, windows 7 machine will start showing up there.



By using above values, we can build a simple and single instance query.
When required we can build complex queries by using “and” or “or” or “NOT”.
When using “and” or “or “ or in a complete query use the brackets to separate the conditions.

No comments:

Post a Comment