In the foreach block of the add members command, check if the group exists and create it if needed.
From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On Behalf Of Heaton, Joseph@Wildlife Sent: Wednesday, June 4, 2014 4:26 PM To: 'scripting@lists.myitforum.com' Subject: [scripting] Powershell question I need to create 50 DLs, and add multiple members to each DL. I have one CSV file to do this, at the moment. I have 2 columns, first is the DL name, and the 2nd is a list of e-mail addresses that need to be in that DL, separated by commas in the cell. I know I can use this command to create the DLs: Import-Csv C:\DLs.csv | ForEach { New-DistributionGroup -Name $_.Name -Alias $_.Alias -Type "Distribution"} And I know I can use this command to add members to a DL: Import-CSV FileName.csv | ForEach {Add-DistributionGroupMember -Identity "GROUP-NAME" -Member $_.Name} However, I don't know if it is possible to use the bottom command in conjunction with the first, to create the group and add the members. I also don't know if I can use the single cell with multiple e-mail addresses in it, separated by commas. (i.e. joe.sm...@xyz.gov<mailto:joe.sm...@xyz.gov>, suzy.jo...@xyz.gov<mailto:suzy.jo...@xyz.gov>, jim.flana...@xyz.gov<mailto:jim.flana...@xyz.gov>) I am going to continue to dig on the internet, but I was hoping someone here might have an idea, as well. Thanks, Joe Heaton Enterprise Server Support Information Technology Operations Branch Data and Technology Division CA Department of Fish and Wildlife 1807 13th Street, Suite 201 Sacramento, CA 95811 Desk: (916) 323-1284