Solved

PS Script to manage users in AD

Posted on 2013-02-06
4
250 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: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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A procedure for exporting installed hotfix details of remote computers using powershell
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…

825 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