Skip to content

Collection based on Users in OU

Featured Replies

Trying to create a collection that will automatically query and update based on users in an OU. Would like to set it up so we can add more queries that will populate users from other OUs as well. Will help with software distribution after training. as well as when users are moved base on new job position.

 

Thank you for any help! B)

1. Create a new collection.

2. On the Membership Rules page, enable "Update this collection on a schedule" and configure your schedule, and then enable "Dynamically add new resource" (if the option is available)

3. Click on the new Query Rule button and give the query a name, choose User Resource as the resource class, and then click on Edit Query Statement.

4. Click on the Criteria tab and then click on the Show Query Language button.

5. Type the following query into the Query Statement field:

 

select SMS_R_USER.ResourceID,SMS_R_USER.ResourceType,SMS_R_USER.Name,SMS_R_USER.UniqueUserName,SMS_R_USER.WindowsNTDomain from SMS_R_User where SMS_R_User.UserOUName = "<YOUR DOMAIN>/<YOUR OU>"

 

Make sure to replace <YOUR DOMAIN> with the NetBIOS name of your domain and <YOUR OU> with the name of your OU.

If that doesn't work, verify the name of the OU by right-clicking on the user in SCCM and looking at the value of the User Container Name[0] property.

The value of User Container Name[0] should take the place of <YOUR DOMAIN>/<YOUR OU> in the query.

 

Also, keep in mind that the Active Directory User Discovery plays a part in how often this collection will be updated, not just the collection update schedule.

  • Author

Thank you josharldt! I will test it out and post results.

 

Have a good one. B)

  • Author

josharldt hit it on the money. Worked for me! Hope this helps someone else. ^_^

  • 9 months later...

Hey guys, does anyone know or have had any luck using a query with multiple OU's?

I want to add two OU's in the same query to add the computers from each of the seperate OU's.

 

I tired adding the system resourse and then the system resource OU etc as usual (e.g. for OU 1), and then added another OU (e.g. OU2) but it showed 0 computers. For the mean time I have had to deploy the same things to seperate OU collections but I would like to keep it down to just one :)

 

 

Any ideas?

Is this in the same query?

 

You can add a second seperate query to the collection, in fact you could add as many seperate queries to a collection as you need instead of trying to have all in the one query!

  • 2 weeks later...

So here is the second part to that query.

 

Does anyone know how to get that same query to remove computers that are no longer in that OU? It seems to add them just fine bu when you move a computer out of that OU an into another, they seem to stick in the collection and get added to the new collection as well.

Does anyone know how to get that same query to remove computers that are no longer in that OU

 

It should do this automatically hence the query rule....give it time, run update membership on collection or run system discovery from discovery methods if in a panic to see it happen..

 

Rocket

It should do this automatically hence the query rule....give it time, run update membership on collection or run system discovery from discovery methods if in a panic to see it happen..

 

Rocket

 

Yeah you were right... I keep forgetting its "SMS" Slow Moving Software.

Just change the update schedule of all your collections to a more aggressive time(15mins or use delta discovery on the collections instead of full update).....this will automate it for you and speed up your slow moving software if you are continuously moving systems from OU to OU in AD!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.