Solved

PS Script to manage users in AD

Posted on 2013-02-06
4
252 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 40

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 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

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

724 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