No one has responded to this discussion for at least a year, so this information may be out of date. If you're looking for information about this topic, please search for a more recent discussion or post a new question.

Add members to Distribution Group with PowerShell

  • Hi,

    One of our customers recently moved to Office365 and because they have system company we had to create list of 900 external contacts. It was pretty easy - PowerShell + CSV. However now we need to divide those users between 12 Distribution Groups and I can't get how can I do it with PowerShell. 

    Basically I'm looking for PowerShell command I can use to force number of users out of .CSV file to become members of Distribution Group. Could you help as me with it?


    Konstantins Sablukovs

    1 out of 1 people found this post helpful.

  • Hello Konstantins Sablukovs,

    I can confirm that you can use PowerShell to modify the members of a distribution list. You can see the "Set-DistributionGroup" PowerShell commandlet from:

    You can also see the following articles for more information about working with distribution lists in Office 365: (Use ECP to manage DL's) (Use PowerShell to manage DL's)

    If you have any more questions about updating your distribution groups, please let us know and I will try to update the thread tomorrow. Thanks!

  • Hi Konstantin

    I have the same challenge at the moment. Did you manage to solve it?


    Ronnie Løgager

  • Nevermind.

    Solved it myself :-)

  • Ronnie, can you share please?

  • 1.Manually Create the Distribution Group on the Portal

    2. Create a CSV file named DLMembers.csv with the following two fields:

    • Identity (Input the existing DL Alias in this field)

    • Members (Input the email address of the users in this field)

    3.Now copy and paste the following script in Notepad and save it as Members.ps1


    $DL = Import-Csv -Path "C:\DLMembers.csv"

    $DL | ForEach-Object {

    $Members = $_.members

    $Identity = $_.Identity

    Add-DistributionGroupMember -Identity $Identity -Member $Members -BypassSecurityGroupManagerCheck



    4.Drag and drop in windows Powershell and hit enter.

  • @music insane : when you say : "• Members (Input the email address of the users in this field)"

    do you mean 1 user per line, or can you add multiple users on one single line ? And in this case how do you separate the users ? comma, space, other ?

    Thanks for your help