Solved

powershell add multiple users to multiple groups

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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …

691 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