Adding users to AD Groups with PowerShell

If you are adding a number of users or computers within Active Directory to one or more groups it can be time consuming.  I needed to add AD objects into groups, over time, sometimes with duplicate objects in the source data and the group, so created a txt file per AD group and a small script (one code block per group/file) to help with the additions.

My source text files were raw lists, plain text, one entry per line.

When the script is run, it will add all the entries in the relevent .txt file into the relevent group.  This allows you to add to the text file with additional lines, even if there is the odd duplicate, and providing it matches a valid AD object, it will get added!

A nice time saver…..

Script Output

Files….



These groups were linked to GPS’s and software rollout tasks but they could be for anything, I have also used this for exchange mailbox operations and more.

Enjoy.

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *