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.