Many organizations still use Active Directory groups or Organisational Unit to do operational tasks in SCCM. Sometimes, they use OU to classify their devices or users. Many will tell that it’s not the most efficient way to do it but it’s effective for some. This blog post will describe how to do a script to create SCCM Collections based on AD OU.

We’ve seen many Active Directory having thousand of different Organisational Units and been asked to create SCCM collection based on those Active Directory OU. This has to be a tedious and boring task. PowerShell to the rescue!

I searched on the internet and found some script that was useful but decided to pimp it a bit to make it really easy for any administrators to create an SCCM collection based on OU.

The script will :

  • List all Organisational Unit (OU)
  • Prompt the Administrator to select the topmost OU where they want to start creating
  • Prompt the Administrator for a folder name
  • The script will create the folder in SCCM
  • The script will create 1 collection per OU from the start OU and will create 1 collection for all OU under the start OU. See the example below if it’s unclear.
  • The script will move collection in the specified folder

We tested the script on our lab server which is running SCCM 1910. The script will work on any SCCM version.

SCCM Collections AD OU – Example

In our lab, we have the following Active Directory structure :

SCCM Collections AD OU
  • I want to create 1 collection for all OU under SCD / Computers
SCCM Collections AD OU
  • I launch the script and select #5
SCCM Collections AD OU
  • The script will create 4 collections and put all members in it
  • SCD / Computers
  • SCD / Computers / Finance
  • SCD / Computers / Administration
  • SCD / Computers / HR

See it in action :

SCCM Collections AD OU

And the Result in SCCM :

SCCM Collections AD OU

Script Download

You can download this SCCM Collections AD OU script from my Microsoft Gallery page.

We hope this script will be useful for you. Let us know what you think in the comment section below.

Comments (12)


02.09.2021 AT 10:38 AM
Hi, Is there a way to change this to import user groups instead? We have over 1200 applications and are moving to SCCM/MCEM, and would like to automate the process of AD User group collections including the dynamic rules for membership. Thanks!

Jonathan Lefebvre

02.09.2021 AT 07:06 PM
Hi, Idea noted, should be possible to do something similar for all groups under a specific OU... I Will look into it thanks Jonathan


02.04.2021 AT 09:09 PM
He Guys, how do I get the script now technet gallery is down..? [email protected] Cheers Stephen

Jonathan Lefebvre

02.05.2021 AT 10:31 AM
Hi Stephen, thanks for pointing this out. I've fixed the link in the post. here it is as well. thanks! Jonathan


06.16.2020 AT 03:01 PM
FYI, The script presumes that the program files for ConfigMan are install on a "D" drive and in a default folder path. I changed the line: Import-Module 'D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' to: Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" This gets around that. I install the program to a "P" drive on my boxes.


06.13.2020 AT 08:52 AM
Hi, Nice One, i am inspired from your script and will create a free tool GUI that let create also the user collection, edit specific name and chose also the limiting collection. All the details is here, I will be delighted to have your return, Thanks


03.02.2020 AT 04:50 PM
What will the membership rules be? Will it be directly adding the current objects in each OU, or will it be setting a query, so it will remain updated as the AD OUs have objects added and removed? Thanks,

toni swinfield

01.29.2020 AT 05:44 AM
Not being great at powershell it would be handy to point out where I need to edit the script?


02.27.2020 AT 01:00 PM


01.22.2020 AT 09:08 AM
Great work - but if i want to create collections from all security groups within the same OU what needs to be changed to the scripts?? THX

Ashwini kumar

01.12.2020 AT 12:37 PM
Great work


01.08.2020 AT 07:35 AM
This is good.... I'd defo use this 🙂