Exclude resources from direct membership rule
I'm trying to create a new collection that includes all of teh PCs except ones with a specific character at the end of the computer name that are already in the All Workstation or Professional Systems collection.
Our computers names are 3 letters, a 3-digit number, followed by an optional character specifying the computer's role. Example: ABC123L. The first three letters are always the same, the 3-digit number is unique to each computer, and not all
computers have the trailing letter (i.e. ABC456).
On the Search For Resources screen of the Create Direct Membership Rule Wizard, I'm searching for System Resources named "ABC%". Are there any special characters I can use to match and exclude a part of the name? I don't want computers like "ABC%Z".
July 12th, 2011 5:24pm
I think what I would do is a subselect.
First, under +Collections, make up a query that is select resourceid from sms_r_system where netbios_name like 'ABC%Z'; confirm that works. Copy and paste that query into notepad. (You can delete this collection now, it was just to prove to
yourself you have the logic right in the query you'll use in the subselect).
under Collections, make a collection query like this:
select resourceid from sms_r_system where
netbios_name like 'ABC%'
AND
resourceid not in (that query from notepad)
Get it? You want all the ABC%, unless they happen be to in that other select statement, the one ending in Z's.
If there are multiple not in's, make sure you put ( ) around the right stuff, like
select resourceid from sms_r_system where
netbios_name like 'ABC%'
AND
(
resourceid not in (select resourceid from sms_r_system where netbios_name like 'ABC%Z')
OR
resourceid not in (select resourceid from sms_r_system where netbios_name like 'ABC%L')
)
Standardize. Simplify. Automate.
Free Windows Admin Tool Kit Click here and download it now
July 12th, 2011 8:48pm
Thanks, that's almost exactly the query I needed.
Select resourceid From sms_r_system Where
name Like 'ABC%'
AND
resourceid Not In (Select resourceid From sms_r_system Where name Like 'ABC%Z')
July 13th, 2011 9:54am
Small tip.
netbios_name is indexed. Name is not. That's why I recommend netbiosname instead of using name in your queries. Sure, it's a small thing, really. but SQL is happier when it gets to use indexed objects. You'll get a teeny tiny
increase in speed of your queries if you use the indexed value of netbiosname.Standardize. Simplify. Automate.
Free Windows Admin Tool Kit Click here and download it now
July 13th, 2011 10:00am


