Powershell Script for mass Group membership

Posted on 2009-04-27
Last Modified: 2012-08-13
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!
Question by:brianroma
    LVL 70

    Accepted Solution


    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


    Author Closing Comment

    It works like champ, Chris!!

    You rock--thanks!


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    A post on a forum I visit frequently mobilized me to create a script to remove a password (the one required to open a file) from any number of Word files. Because nobody would want to open a 100 files and manually save them... Of course, you have t…
    Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now