sms: selecting objects not in a collection
if you were interested in a way of retrieving objects into a collection that don't exist in another collection, it's actually not very difficult. for example, you have a collection of clients with antivirus. now you want to create a collection of clients that do not have antivirus. instead of creating a new one, you run subselect to bring back all the clients that are not in the original antivirus collection.
the only thing you have to know is the collection id of the collection that you want to check. for the samples below, note that [collid] is a generic tag for your collection ids. if you examine the root\sms\site_
sms_cm_res_coll_[collid]
this is what you need to build your subselect query. if you query this in wbemtest, with something like select * from sms_cm_res_coll_[collid] you should get back a list of resource ids which look something like this:
... sms_cm_res_coll_[collid].resourceid=1 sms_cm_res_coll_[collid].resourceid=2 sms_cm_res_coll_[collid].resourceid=3 sms_cm_res_coll_[collid].resourceid=4 sms_cm_res_coll_[collid].resourceid=5 ...
or something similar... i was showing that part just to demonstrate that querying the collection id from wmi in this manner, does indeed produce the members of the collection. now to put it all together, this is how you'd build your subselect query.
select sms_r_system.resourceid, sms_r_system.name from sms_r_system where resourceid not in ( select sys.resourceid from sms_cm_res_coll_[collid] AS coll, sms_r_system as sys where sys.resourceid = coll.resourceid )
in effect, this would be the same as building a collection that's limited to another collection. the only difference is that when you're using limiting collections, you can't specify to retrieve where a machine doesn't exist in a certain collection.
(btw, you can execute that wql query in wbemtest. works quite nicely. output has a lot to be desired though...)
as a follow on note, kim oppalfens wrote this little post recently on figuring out the collectionid for linked collections.
Thank you, popped right up in a Google search and was exactly what I needed - Ivan
ReplyDeletegreat to hear it ivan. i guess i can thank google for doing its job. :)
ReplyDeleteby the way, i revised and cleaned this up. i'm slowly trying to change formatting wherever i see that a particular post is useful.
thanks for commenting!
Thank you, popped right up in a Google search and was exactly what I needed - Ivan
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete