Solved

powershell add multiple users to multiple groups

Posted on 2013-11-19
2
1,806 Views
Last Modified: 2014-03-13
Good morning I have a huge issue. I am trying to add multiple users to multiple groups with an input file. I have searched for this on the net and mostly I see where you have to indicate each group and then you can go through your input file. I would like to know how can this be done with multiple groups and users in an input file. For example below.


DLNAME    member
dldistro1    usersomeone
dldistr01    usersomeone2
dldistr02    something
dldistro02 somethingagain
dldistro03  jane.doe
dldistro04  john.doe

I was using this as my code

import-csv c:\temp\dlmembers.csv | foreach {add-distributiongroupmember -identity "groupnane" -member $_.Member }
0
Comment
Question by:techdrive
2 Comments
 
LVL 35

Accepted Solution

by:
Joseph Daly earned 500 total points
ID: 39659493
You code looks like it should work what happens when you run it. Only change I made was to change the identity to use the CSV file heading.

import-csv c:\temp\dlmembers.csv | foreach {add-distributiongroupmember -identity $_.DLNAME -member $_.Member }
0
 

Author Comment

by:techdrive
ID: 39659511
THATS WHAT it was thanks
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

A brief introduction to what I consider to be the best editor for PowerShell.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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…
This video discusses moving either the default database or any database to a new volume.

863 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

27 Experts available now in Live!

Get 1:1 Help Now