Solved

PS Script to manage users in AD

Posted on 2013-02-06
4
248 Views
Last Modified: 2013-03-01
Hey all, I am trying to use powershell to add a user to about to 25 groups. I could easily do the copy method when creating the user on the fly. The request to add to the groups came after the creation of the user, and I don't want to delete and start over. What I did for starters is export the group listing from an existing user. Now I want to find a way to run a script that will look at the list of groups, then add the user to all of them. (Here comes the suggestion to use Quest, lol). I would love to use Quest, but I want to be able to share the script with my team, I am the only one that has the Active Roles Management installed. So, a traditional powershell script would be nice.
0
Comment
Question by:xzay1967
4 Comments
 
LVL 39

Expert Comment

by:footech
ID: 38862211
Do you have a 2008 R2 (or newer) DC?
0
 

Author Comment

by:xzay1967
ID: 38862213
Sorry forgot to mention my environment, it is 2008R2
0
 
LVL 35

Expert Comment

by:Nick Sui
ID: 38862413
There are a number of PowerShell scripts available which does what you need.

What you need is a For Loop to process list of groups from a text file.

Please hold while I create one for you!

I am also designing a tool which will do the job easier and save IT admins time.

-----
Sys.
0
 
LVL 10

Accepted Solution

by:
Prashant Girennavar earned 500 total points
ID: 38862549
Below is the script.

import-module activedirectory

$b = Read-Host"Provide the User Account"
$a = get-content C:\Group.txt
Foreach($group in $a)
{
Add-ADGroupMember -Identity $group -Members $b
}

Open in new window


Here ,
 $b = The user account Name which needs to be added to the group

The groups should be listed in C:\Group.txt file

Hope this helps

Thanks,

_Prashant_
0

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

747 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

8 Experts available now in Live!

Get 1:1 Help Now