Powershell – Adding all Computers from an OU into a Group

This is a pretty simple script. It searches an OU for all computer objects, and adds them to a group. I needed to restrict certificate auto-enrollment permissions on the SCCM Certificate Templates to all computers in an OU and sub-OU’s. It runs every 5mins on our SCCM server.


It’s named ‘Add-OUComputersToGroup.ps1′ and is available on my Github repo here: Jpuskar’s Github Page.


Change the variables at the top.

$rootOU – the DN of the root where you want to start searching.
$tgtGroupCN – the group you want computer objects to be placed into.

Good luck!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s