Using Quest ActiveRoles Management Shell to add/update all users from a OU inside an AD group

Abstract: I recently need a way to add all users to a AD group and keep the group up to date on a scheduled basis. I accomplished that task with the Quest ActiveRoles Management Shell.

Note: This script required the "Quest ActiveRoles Mangement Shell Version 1.5.1" which is the latest known free version. It can be found in the internet if needed.

HowToUse:

You need to specify the AD OUs (Example: DE1, DE2, DE3,...) inside the script and create the needed groups (Example: DE1-Sharepoint-Users, DE2-Sharepoint-Users, DE3-Sharepoint-Users, ...). If you then run the script it checks the members inside the given OU and added them to the given AD group for that OU (if the user is still missing in that group).

# Assign all non existing members of the group to a dynamic array Write-Host "Build array with agents which are missing in the group" -foregroundcolor Black -backgroundcolor Green $NonAgentGroupMembers = Get-QADUser -searchroot "emea.contoso.com/$OrgUnit/Agents" -NotMemberOf "$OrgUnit-Sharepoint-Users"

# Assign all non existing members of the group to a dynamic array Write-Host "Build array with staff user which are missing in the group" -foregroundcolor Black -backgroundcolor Green $NonUserGroupMembers = Get-QADUser -searchroot "emea.contoso.com/$OrgUnit/Staff" -NotMemberOf "$OrgUnit-Sharepoint-Users"