ConfigMgr Exclude computer from collection if in two groups
Found this old article from Matthew Hudson about testing if a computer is in two group. Thanks Matthew! While he mention groups and OUs, his example was OU only. So here is the modified for Groups. Works like a charm! If the computer is in both groups, it's excluded from the collection. This is useful if you've got non admins managing group memberships. 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 inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Name not in (select distinct SMS_G_System_COMPUTER_SYSTEM.Name from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_R_System.SecurityGroupName = "domain .local\\groupB" ) and SMS_R_System.SecurityGroupName =...