Exchange Management Shell
I would like to add users to distribution list in bulk. let say i have 5 differents distributions name and i have 10 user, each user will be member of these 5 distributions list. I would like to import from csv file. My csv file is look like:
Alias Distri1 Distri2 Distri3 Distri4 Distri5
User1 mailing1 mailing2 mailing3 mailing4 mailing5
User2 mailling1 mailing2 mailing3 mailing4 mailing5
User3
User4
.
What cmdlet, i used currently is like this:
Import-Csv c:\newuser.csv | foreach { Add-DistributionGroupMember -Identity $_.distri1 -Member $_.alias }
Import-Csv c:\newuser.csv | foreach { Add-DistributionGroupMember -Identity $_.distri2 -Member $_.alias }
Import-Csv c:\newuser.csv | foreach { Add-DistributionGroupMember -Identity $_.distri3 -Member $_.alias }
Is there any one cmdlet to funfill this requirement
Thank
June 30th, 2010 6:08am
Hi,
Try this it might help :
$groups = import-csv c;\temp\groups.csv
$users = "User1","User2","User3"
foreach ($group in $groups){
foreach ($user in $users){
add-distributiongroupmember $group.name -member $user
}
}
If you have the list of users in a .txt file (e.g. c:\temp\users.txt) , you can use that by replacing
$users = "User1","User2","User3"
with
$users = get-content c:\temp\users.txt
Ripu Daman Mina | MCSE 2003 & MCSA Messaging
Free Windows Admin Tool Kit Click here and download it now
June 30th, 2010 12:44pm
And the groups.csv should be:
name
mailing1
mailing2
mailing3
...
And uses.txt:
User1
User2
...
Frank Wang
July 5th, 2010 10:36am
Just tested..it is working like charm. Just curios why:
Can't used uses.csv no header name need for uses.txt
Thank
Free Windows Admin Tool Kit Click here and download it now
July 14th, 2010 5:44am