Add members to Distribution group from CSV
Hello,I have recently asked how to generate a Ditribution group creation using a CSV file.Here the shell command used:Import-CSV C:\TEST_DG.csv | foreach {new-distributiongroup -name $_.name -samaccountname $_.SAM -type distribution -org Company/DG} | Set-DistributionGroup -RequireSenderAuthenticationEnabled $FalseHere the CSV file used:Name,SamDG1, DG1DG2, DG2DG3, DG3--> Now I need to add users:User1User2User3to the Distribution groups I have created with the above shell command.Can someone help me out with that??
February 9th, 2010 1:57pm
$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
Free Windows Admin Tool Kit Click here and download it now
February 9th, 2010 4:32pm