Exclude Active Directory OU’s from a Collection in System Center Configuration Manager 2007 | Quisitive
Exclude Active Directory OU’s from a Collection in System Center Configuration Manager 2007
February 23, 2010
Quisitive
Here’s a great script I thought about sharing...

Here’s a great script I thought about sharing since I find it to be very handy to assist for the following requirement.

Create a “all computers” collection for software updates and exclude various OU’s that have computers not allowed to be updated for various reasons.

Please modify the BOLD areas with the correct information. The great part is, you don’t have to spell out the full OU name to be excluded.

Script

select sys.ResourceId, sys.ResourceType, sys.Name, sys.SMSUniqueIdentifier, sys.ResourceDomainORWorkgroup, sys.Client
from SMS_R_System as sys where sys.SystemOUName like “TEST.COM/COMPUTERACCOUNTS
and sys.ResourceId not in (select ResourceID from  SMS_R_System where SMS_R_System.SystemOUName like “%OuNameToNotInclude“)
and sys.ResourceId not in (select ResourceID from  SMS_R_System where SMS_R_System.SystemOUName like “%OuNameToNotInclude“)
and sys.ResourceId not in (select ResourceID from  SMS_R_System where SMS_R_System.SystemOUName like “%OuNameToNotInclude“)