I have a csv that goes something like this:
DLName,member
DistList1,fergus,john,ian
DistList2,fergus,James,Angus
I need to create DistList1, DistList2 etc and add as members all those users after it. There are hundreds of users, and 2800 groups.
I can create the groups ok by using:
$file = import-csv c:\DLs.csv
foreach ($line in $file) {New-DistributionGroup -name $line.DLName}
but no idea how to add the users.
I've changed the data so it reads:
DLName,member
DistList1,"fergus,john,ian"
i.e. all members/users are in the same cell, but when I try:
Import-Csv c:\dls.csv | foreach {add-adgroupmember $_.DLName -Members $_.members}
it gets upset because 'fergus,john,ian' is not a single user. I need to split them somehow.
Can someone help?
Thanks in advance,
F.