Solved

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

Posted on 2014-01-03
1
379 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
This video discusses moving either the default database or any database to a new volume.
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…

751 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