Import multi-value csv cells into Powershell
i have csv goes this:
dlname,member
distlist1,fergus,john,ian
distlist2,fergus,james,angus
i need create distlist1, distlist2 etc , add members users after it. there hundreds of users, , 2800 groups.
i can create groups ok using:
$file = import-csv c:\dls.csv
foreach ($line in $file) {new-distributiongroup -name $line.dlname}
but no idea how add users.
i've changed data reads:
dlname,member
distlist1,"fergus,john,ian"
i.e. members/users in same cell, when try:
import-csv c:\dls.csv | foreach {add-adgroupmember $_.dlname -members $_.members}
it gets upset because 'fergus,john,ian' not single user. need split them somehow.
can help?
thanks in advance,
f.
hi,
here's example can play with:
$str = 'fegus,john,ian' $strsplit = $str -split ',' $strsplit
don't retire technet! - (don't give yet - 13,225+ strong , growing)
Windows Server > Windows PowerShell
Comments
Post a Comment