If you are looking for a SCCM query query that will return all machines that are in a specified organisational unit (OU), then you can use this one below.
All you need to do is change the demo OU below to your own required OU.
SELECT distinct * FROM SMS_R_System WHERE SMS_R_System.SystemOUName = “TECHYGEEKSHOME/LAB/COMPUTERS/WINDOWS 7”
This will then return all machines in the specified OU along with a large amount of information for each machine.
Our full range of SQL and WQL Collection queries are available here.
If you have any questions or feedback about this post, or if you would like us to create any queries for you, please go ahead and leave us a message below in the comments section and we will get back to you as quick as we can.