Powershell Script for mass Group membership

Hey guys!!

I am working on an Active Directory group cleanup (to the tune of 600+ groups deleted and 450+ groups created and populated) project.

I got help from EE last week on how to create a list of groups from a reference .CSV file. I am trying to get a script going that would reference a list of users (i..e):

Bob Roberts
Mike Michaels
Jimmy James

...and add them to a list of groups

Information Technology
Information Technology-Private Files
Information Technology-Mail Distribution

I have the Quest cmdlets installed.

Any help you could provide would be awesome!
Who is Participating?
Chris DentConnect With a Mentor PowerShell DeveloperCommented:

So if you had a list of users in a text file we could do something like this.

I reckon this will need some tweaking, but it's a reasonable enough place to start.

Get-Content "TextFile.txt" | %{
  $UserDN = (Get-QADUser $_).DN
  Add-QADGroupMember "Information Technology" -Member $UserDN
  Add-QADGroupMember "Information Technology-Private Files" -Member $UserDN

Open in new window

brianromaAuthor Commented:
It works like champ, Chris!!

You rock--thanks!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.