Solved

Adding users to group from text file sideways Exchange 2010 powershell question

Posted on 2014-01-03
1
369 Views
Last Modified: 2014-01-09
Hello guys I have a quick question about powershell. I have an input file and the it is a bit differentthan what I am use to working with. The following is displayed this way.

groups                            users
Group                   user,user5, user9, user user03, user32, user83,user84
group2                  anotheruser,  anotheruser1,  anotheruser93,anotheruser893
0
Comment
Question by:techdrive
1 Comment
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 500 total points
ID: 39754078
Might be a little easier to use a CSV file. I have created 2 scripts below as I am not sure if you are talking about AD Groups (security) or Distribution Groups. 1st script is for Distribution Groups, 2nd is for AD Security.

Construct your CSV file like below (same CSV file for both scripts)
Groups  Users
Group1  user1
Group1  user2
Group1  user3
Group2  user9
Group2  user7

Distribution Group Bulk Add
Add-PSSnapin Microsoft.Exchange.Management.Powershell.E2010
$GroupList = Import-Csv "c:\mycsv.csv"
foreach ($Group in $GroupList) {
$Group.Groups
$Group.Users
Add-DistributionGroupMember -Identity $Group.Groups -Member $Group.Users
}

Open in new window


Security Group Bulk Add
Import-Module activedirectory
$GroupList = Import-Csv "c:\mycsv.csv"
foreach ($Group in $GroupList) {
$Group.Groups
$Group.Users
Add-ADGroupMember -Identity $Group.Groups -Members $Group.Users
}

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

895 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

14 Experts available now in Live!

Get 1:1 Help Now