Link to home
Start Free TrialLog in
Avatar of cawasaki
cawasaki

asked on

powershell script to create bulk distribution list on exchange 2013

hello,

i need a powershell script to create bulk distribution list on exchange 2013, the DL must be created in specific OU in Active Directory

 i have a csv entry file like this:

DisplayName,Name,Email,Description
@DL_Neywork,DL_Neywork,DL_Neywork@contoso.com,"distribution list of new yor people"
........

a distribution list may already exist on the list, so i need to have a log file say:

dl_newyor created succesfully
or
dl_newyor created already exist
.....

thnaks for help
Avatar of Rohit Anand
Rohit Anand
Flag of India image

Hey,

You can use below script to create bulk distribution list in Exchange Server
Create a CSV File, and give the heading of the first column header as DisplayName and keep all distribution list name in that column.
You can check out attach CSV file for help.
Once you will save it, Execute below commands

$a = import-csv "Give the CSV file path"
$a | foreach-object{New-DistributionGroup -Name $_.DisplayName -OrganizationalUnit "OU Details" -Type "Security"}

Do execute it, and let me know, in case if you face any issue.
DLCreationCSVFormat.csv
Avatar of cawasaki
cawasaki

ASKER

hello,

distribution list must be not security group so they can not be used to attribute any ntfs right or other and will be easily deleted in the future

possible?

and the csv file must be like this one because already exist:

DisplayName,Name,Email,Description
@DL_Neywork,DL_Neywork,DL_Neywork@contoso.com,"distribution list of new yor people"
.....


thanks
Hey,
Incase, if you don't want these distribution list to be security group. You can change the Type to " Distribution"

Yes, it will be easily deleted in future.

I didn't got the last one where you say Distribution list already exist.
@rohit Anand

your sript does not do all what i want,

the csv file is like this:

DisplayName,Name,Email,Description
@DL_Neywork,DL_Neywork,DL_Neywork@contoso.com,"distribution list of new yor people"
........

so the script must create Distribution list on specific OU and set the description

thanks for help
Hey, What I understand that you wanted to have script which will create a bulk DL, in a specific OU, Email Address, and Description.. Do let me know, in case I am wrong
yes but your script code not do all what i ask and specially not take my csv input?
Yes, it will not take.

Can you please let me know few more details,
Do you want to keep common description for each DL?
cawasaki,
This is pretty straight forward.

Import-Csv "enterfilepathofyourcsvfile" | %{New-DistributionGroup -Name $_.Name  -DisplayName $_.DisplayName  -PrimarySmtpAddress $_.Email -Type Distribution -Notes $_.Description -MemberDepartRestriction Closed -MemberJoinRestriction Closed -verbose}
You may also capitalize on your .csv by adding a column ManagedBy and list the owners you would like of the dl by email address
Example:

DisplayName,Name,Email,Description,Managedby
@DL_Neywork,DL_Neywork,DL_Neywork@contoso.com,"distribution list of new yor people",JDoe@yourdomain.com  

the script would now read

Import-Csv "enterfilepathofyourcsvfile" | %{New-DistributionGroup -Name $_.Name  -DisplayName $_.DisplayName  -PrimarySmtpAddress $_.Email -Type Distribution -Notes $_.Description  -managedby JDoe@yourdomain.com -MemberDepartRestriction Closed -MemberJoinRestriction Closed -verbose}
ASKER CERTIFIED SOLUTION
Avatar of Jeff Glover
Jeff Glover
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial