Collection Query
It's probably very simply but just can't get a finger on it. I have the following query on a collection and what i want it to do is pull everthing I ask but the problem is i need the query to exclude any client that is in the system group SCCM_SERVER_EXCEPTIONS group regurdless if it's in any other group I'm quering. It works for the most part except if it's memeber of more than 1 group. What i want to accomplish is I want any machine that is a server, who has a client is and is active and is a member of any system groups named Reboot or any of our mantance window collections but is not in groups named (No Reboot) or the group SCCM_SERVER_EXCEPTIONS Any ideas? 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 "Microsoft Windows NT %Server%" and SMS_R_System.Active is not null and SMS_R_System.Client != 0 and SMS_R_System.Client = 1 and SMS_R_System.ResourceId in (SELECT ResourceID FROM SMS_R_System WHERE SMS_R_System.SystemGroupName like "domainname\\%(Reboot)%" and SMS_R_System.ResourceId not in (SELECT ResourceID FROM SMS_R_System WHERE SMS_R_System.SystemGroupName = "domainname\\SCCM_SERVER_EXCEPTIONS" or SMS_R_System.SystemGroupName like "domainname\\%(No Reboot)%") or SMS_R_System.ResourceId in (select ResourceID from SMS_FullCollectionMembership where collectionid = 'NAB00188' or collectionid = 'NAB00187' or collectionid = 'NAB0023E' or collectionid = 'NAB001A0' or collectionid = 'NAB00265' or collectionid = 'NAB00264' or collectionid = 'NAB00189' or collectionid = 'NAB001F8')))
May 1st, 2012 8:08am

try this not tested... it is only missing the AND case or Brackets .. not the OR... try to change here and there... 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 "Microsoft Windows NT %Server%" and SMS_R_System.Active is not null and SMS_R_System.Client != 0 and SMS_R_System.Client = 1 and SMS_R_System.ResourceId in (SELECT ResourceID FROM SMS_R_System WHERE SMS_R_System.SystemGroupName like "domainname\\%(Reboot)%" and SMS_R_System.ResourceId not in (SELECT ResourceID FROM SMS_R_System WHERE SMS_R_System.SystemGroupName = "domainname\\SCCM_SERVER_EXCEPTIONS" and (SMS_R_System.SystemGroupName like "domainname\\%(No Reboot)%") or SMS_R_System.ResourceId in (select ResourceID from SMS_FullCollectionMembership where collectionid = 'NAB00188' or collectionid = 'NAB00187' or collectionid = 'NAB0023E' or collectionid = 'NAB001A0' or collectionid = 'NAB00265' or collectionid = 'NAB00264' or collectionid = 'NAB00189' or collectionid = 'NAB001F8'))))This posting is provided "AS IS" with no warranties or guarantees, and confers no rights. Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. Click on "vote as Helpful" if you feel this post helpful to you. This can be beneficial to other community members reading the thread. ------------------------------------------------ PaddyMaddy | http://paddymaddy.blogspot.com/
Free Windows Admin Tool Kit Click here and download it now
May 1st, 2012 8:14am

K that worked for removing things in the exceptions group but it's also excluding everthing in SMS_R_System.ResourceId in (select ResourceID from SMS_FullCollectionMembership where collectionid = 'NAB00188' or collectionid = 'NAB00187' or collectionid = 'NAB0023E' or collectionid = 'NAB001A0' or collectionid = 'NAB00265' or collectionid = 'NAB00264' or collectionid = 'NAB00189' or collectionid = 'NAB001F8')))) I do want any item in these collections as long as they are not in the exceptions group
May 1st, 2012 8:35am

Think I got it... 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 "Microsoft Windows NT %Server%" and SMS_R_System.Active is not null and SMS_R_System.Client != 0 and SMS_R_System.Client = 1 and SMS_R_System.SystemGroupName like "domainname\\%(Reboot)%" or SMS_R_System.ResourceId in (select ResourceID from SMS_FullCollectionMembership where collectionid = 'NAB00188' or collectionid = 'NAB00187' or collectionid = 'NAB0023E' or collectionid = 'NAB001A0' or collectionid = 'NAB00265' or collectionid = 'NAB00264' or collectionid = 'NAB00189' or collectionid = 'NAB001F8')) and SMS_R_System.ResourceId not in (SELECT ResourceID FROM SMS_R_System WHERE SMS_R_System.SystemGroupName = "domainname\\SCCM_SERVER_EXCEPTIONS" or SMS_R_System.SystemGroupName like "domainname\\%(No Reboot)%")
Free Windows Admin Tool Kit Click here and download it now
May 1st, 2012 10:16am

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

Other recent topics Other recent topics