Question : Problem: Problems getting collection memberships limited how I want.

I am attempting to define my collections based on the following:
1.) only machines that have the client.
2.) only machines within a certain subnet.
3.) NOT certain IP addresses.

so I use the guides and end up with this SQL statement:


Now the code works so long as there is only one IP address. The problem is that I want to add multiple IP address. You can keep adding "and not" statements, SCCM will let you, but only the first one seems to be evaluated. The rest are ignored. I tested this theory by changing the IP addresses around and only the first would be left out of a collection.
If I create mulitple queries to do this, I end up getting every client in the site added to the collection rather than leaving out the wanted IP's

Code Snippet:
1:
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.IPSubnets like "172.17.0.0" and SMS_R_System.Client = 1 and not SMS_R_System.IPAddresses = "172.17.0.251"
Open in New Window Select All

Answer : Problem: Problems getting collection memberships limited how I want.

Use NOT in syntax for multiple NOT include items.
1:
2:
3:
4:
5:
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.IPSubnets = "172.17.0.0" 
and SMS_R_System.Client = 1 
and SMS_R_System.IPAddresses not in ( "172.17.0.251", "172.17.0.252")
Open in New Window Select All
Random Solutions  
 
programming4us programming4us