Solved

powershell add multiple users to multiple groups

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this video we show how to create a mailbox database 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 Servers >> Data…
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…

730 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