Collections based on the OU

If you are looking for a collection to query all the machines only from a particular OU not the SUB OU .Let say ,I have Top OU called Workstations\comp(120 systems) in domain and in turn it has 3 sub OU's OU1(10 systems),OU2(20 systems),OU3(49 systems).

Here is the simple query to get machines only from TOP OU called workstations.

SELECT sms_r_system.resourceid,
FROM   sms_r_system
WHERE  sms_r_system.systemouname = "" /*find all machines in that OU (but also finds machines in subOUs */
       AND sms_r_system.resourceID NOT IN (SELECT resourceID FROM sms_r_system where systemouname LIKE "") /*remove records for machines in subOUs*/

The above collection should display only machines that are present in comp OU not from the SUB OU's (like OU1,OU2,OU3).

2 Responses to "Collections based on the OU"

Leave a Reply