Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-01-03
1
Medium Priority
?
393 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Eseutil Hard Recovery is part of exchange tool and ensures Exchange mailbox data recovery when mailbox gets corrupt due to some problem on Exchange server.
Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

783 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