Solved

powershell add multiple users to multiple groups

Posted on 2013-11-19
2
1,926 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
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…
how to add IIS SMTP to handle application/Scanner relays into office 365.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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