Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

PS Script to manage users in AD

Posted on 2013-02-06
4
Medium Priority
?
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 41

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:Nirmal Sharma
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 2000 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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

647 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