Querying Configuration Manager Devices by Active Directory OU
If you need to build a Configuration Manager collection or report scoped to a particular Active Directory organisational unit — say, targeting only machines in a specific site or department’s OU — the discovery data includes the OU path, so it’s a straightforward WQL query.select SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SystemOUName from SMS_R_System where SMS_R_System.SystemOUName = "OU=Workstations,OU=London,DC=contoso,DC=com"
SystemOUName is populated by AD System Discovery, so make sure that discovery method is enabled and has run recently, otherwise this field may be empty for machines that haven’t been re-discovered since being moved between OUs.
If you want to catch objects in a nested sub-OU as well as the parent, use a like comparison with a wildcard instead of an exact match:
select SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SystemOUName from SMS_R_System where SMS_R_System.SystemOUName like "%OU=London,DC=contoso,DC=com"
Save either query and use it directly as the membership rule for a device collection if you want it to update automatically as machines move in and out of the OU.
Still Current on Configuration Manager 2603 (Updated for 2026)
This query still works unchanged on the current release (Configuration Manager 2603) —SystemOUName is still populated by AD System Discovery in exactly the same way. One thing worth double-checking if the query comes back empty: AD System Discovery only refreshes OU data on its configured polling interval, so a machine moved between OUs recently may still show its old OU path until the next discovery cycle runs.
Resources
Gear We Recommend
Testing configs is easier with a dedicated admin machine set up right. Here’s the kit we use.
Browse our Windows Admin Toolkit picks on AmazonAs an Amazon Associate, TechyGeeksHome earns from qualifying purchases.
Discover more from TechyGeeksHome
Subscribe to get the latest posts sent to your email.
this worked really well!
thank you very much for posting.
this worked really well!
thank you very much for posting.
this worked really well!
thank you very much for posting.