I’ve recently tried to find a strategy to exclude a set of machines from my WMI queries. While I can compile an enorumous query to exclude the machines I want, this is not a very user friendly approach for those not familiar with ConfigMgr queries. I came across a post from the SMS Guys outlining my exact dillemma.
What you do is simply create a collection with machines to exclude, and administrators can easily add machines to this collection for them to be excluded from the collection you want. This can of course also be combined with queries against that collection if you want to exclude several machines based on a set of rules.
Here’s how you do it:
1. Create an exclude collection. I’ll name mine Software Updates – Windows XP Exclusions. Make note of the Collection ID as you will need this later.
2. Put the machines you want to exclude into the collection. This can also be other queries, as illustrated bellow.
3. Create a new query, I’ll name mine Software Updates – Windows XP Exclusions. Insert the following into the query designer, and make sure you replace the XXX part with your Collection ID.
select SMS_R_System.ResourceId, SMS_R_System.Name, SMS_G_System_OPERATING_SYSTEM.Caption, SMS_G_System_OPERATING_SYSTEM.CSDVersion from SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_OPERATING_SYSTEM.Caption = “Microsoft Windows XP Professional” and SMS_R_System.ResourceId not in (select ResourceID from SMS_CM_RES_COLL_XXXXXXX)
Note that my collection also takes into account Operating System being like ‘Windows XP Professional’.
4. You can now attach the query to a new collection. All the computers from your exclude collection will from now on NOT be a part of this collection. In my case a machine called SMSSERVER, along with the computers I have in my Software Updates – All Windows XP Exclusions query.