none
Powershell / Exchange 2010 : How To Remove ALL Members From A List (CSV) OF Distribution Lists RRS feed

  • Question

  • I have the following csv file ( lets name it del.csv )

    The structure of this csv is like the below example:

    "Column A"

      Group

      DistributionList1

      DistributionList2

      DistributionList3

    I would like exchange to read all "Distribution Lists" on all rows under "column A" And remove ALL members from them.

    Please advise this, Thanks.

    Friday, December 14, 2018 6:50 AM

All replies

  • Hi,

    Is "Group" the column name or a group name? If it is a column name, please change the csv structure as below.

    Group

    DistributionList1

    DistributionList2

    DistributionList3

    After that, you can run the command below to remove members from distribution group.

    Import-csv <file path> | foreach { 
    
    $groupMembers = Get-DistributionGroupMember $_.Group
    Remove-DistributionGroupMember -Identity $_.Group -Member $_.groupMembers
    
    }

    Regards,

    Dawn Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, December 17, 2018 2:02 AM
    Moderator