« ConfigMgr with Service Pack 2 slipstreamed is now available on MSDNLet's dive deeper in ConfigMgr R3 »

Dynamically fill a collection with members that are not part of another collection

12/07/09 | by Jannes Alink [mail] | Categories: System Center, ConfigMgr

Sometimes you have the need to create a collection that is dynamically filled with members that are not part of another collection.

Last time I faced this scenario, was when configuring patch management. At the customer we created two collections. One named ‘Servers – Manual Restart’ and one collection named ‘Servers – Automatic Restart’.

We filled the ‘Servers – Manual Restart’ by hand creating a Direct Membership rule. After that we wanted a query to automatically fill the ‘Servers – Automatic Restart’ collections with servers that were not a member of the ‘Servers – Manual Restart’ collection.

The query below is what I used. In this case ‘P010001B’ is the collection ID of the ‘Servers – Manual Restart’ collection.

SELECT
SMS_R_SYSTEM.ResourceID,
SMS_R_SYSTEM.ResourceType,
SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,
SMS_R_SYSTEM.ResourceDomainORWorkgroup,
SMS_R_SYSTEM.Client

FROM
SMS_R_System
WHERE
SMS_R_System.Client0 like '1' AND SMS_R_System.Obsolete0 like '0'
AND
SMS_R_System.ResourceId NOT IN (SELECT ResourceID FROM SMS_FullCollectionMembership WHERE collectionid IN ('P010001B'))

As with any query you can specify one or more criteria to meet your own specific needs, as in the example above to narrow it further down if a client is installed and if the systems is obsolete or not.

Have fun!

Permalink

Search



Hi,

I'm Jannes Alink and welcome to my blog! I'm living in the Netherlands and working in the IT industry for more than 8 years. I work as freelance consultant at Alinja and deliver projects around the globe. Currently on a project in Abu Dhabi (UAE).

Posts are just my personal opinion.

February 2012
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29        

XML Feeds

powered by b2evolution free blog software