Solved

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

Posted on 2014-01-03
1
368 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
Comment Utility
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

Do email signature updates give you a headache?

Do you feel like all of your time is spent managing email signatures? Too busy to visit every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Join & Write a Comment

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
how to add IIS SMTP to handle application/Scanner relays into office 365.

771 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