Help needed with a collection query
In this query I want to include all PCs running a Windows workstation OS, within the specified IP range and NOT in any OU that has the word "servers" in it. It keeps returning nothing even though I have plenty of PCs that meet the criteria that I'm wanted (looked in resource explorer for a few). 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.OperatingSystemNameandVersion like "%Workstation 5.1%" or SMS_R_System.OperatingSystemNameandVersion like "%Workstation 5.0%" or SMS_R_System.OperatingSystemNameandVersion like "%Workstation 6.0%" or SMS_R_System.OperatingSystemNameandVersion like "%Workstation 6.1%") and SMS_R_System.IPAddresses like "10.211.2.%" and SMS_R_System.SystemOUName not like "%Servers%"
January 4th, 2010 11:28pm

It looks OK but you might want to use subnets instead of IP addresses. I also used in() for the OS name and version because it makes the query shorter and runs faster then using multiple like statements.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.OperatingSystemNameandVersion in ("Microsoft Windows NT Workstation 5.0","Microsoft Windows NT Workstation 5.1","Microsoft Windows NT Workstation 6.0","Microsoft Windows NT Workstation 6.1") and SMS_R_System.IPSubnets in ("10.211.2.0") and SMS_R_System.SystemOUName not like "%Servers%"I also put an in for subnets just to make it a bit easier to add additional subnets if necessary.Scott Gill SCCM Consultant
Free Windows Admin Tool Kit Click here and download it now
January 5th, 2010 12:18am

You could leave out all of the OS stuff between ( and ) and instead limit the collection to the built-in All Windows Workstations collection. John Marcum | http://www.TrueSec.com/en/Training.htm | http://myitforum.com/cs2/blogs/jmarcum
January 5th, 2010 1:26am

Yes but then there would be a delay if a new machine fits the criteria it now also has to go through the collection evaluation cycle on the all windows workstation collection first. I tested the query in my environment (with a different subnet) and it worked just fine.Scott Gill SCCM Consultant
Free Windows Admin Tool Kit Click here and download it now
January 5th, 2010 1:35am

there would be a delay if a new machine..... Very true. I wasn't saying yours was bad or wouldn't work I was just pointing out how to use collection limiting.John Marcum | http://www.TrueSec.com/en/Training.htm | http://myitforum.com/cs2/blogs/jmarcum
January 5th, 2010 1:39am

Fair enough :)Scott Gill SCCM Consultant
Free Windows Admin Tool Kit Click here and download it now
January 5th, 2010 1:45am

Thanks, Scott! Your query worked like a charm for me. I was unfamiliar with the "in" part. I can't use the IP Subnets because our client's network uses a 10.211.x.x/16 subnet and sometimes a /24 so it's much easier for me to use IP ranges.
January 5th, 2010 5:03pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics