[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PS Script to manage users in AD

Posted on 2013-02-06
4
Medium Priority
?
256 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 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

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

Question has a verified solution.

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

Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
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 …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

872 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