Remove DL members

Glenn Maxwell 10,146 Reputation points
2020-12-18T09:15:31.957+00:00

Hi All

i have users list in csv file, i want to remove users from the DL, will the below syntax help me.
users
user1@Company portal .com
user2@Company portal .com

Import-CSV C:\list.csv | ForEach {Remove-DistributionGroupMember -Identity distributionlist@Company portal .com -Member $_.users}

Microsoft Office Online Server
Microsoft Office Online Server
Microsoft on-premises server product that runs Office Online. Previously known as Office Web Apps Server.
585 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,623 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,176 questions
0 comments No comments
{count} votes

Accepted answer
  1. ChelseaWu-MSFT 6,316 Reputation points
    2020-12-21T02:25:06.317+00:00

    I have tested and confirm that the command works fine for removing DL members.

    If you want to skip the built-in confirmation prompt while executing the command, use this exact syntax: -Confirm:$false:

    Import-CSV C:\list.csv | ForEach { Remove-DistributionGroupMember -Identity distributionlist@contoso.com -Member $_.users -Confirm:$false}  
    

    Reference: Remove-DistributionGroupMember.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    **Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. **

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Vasil Michev 95,341 Reputation points MVP
    2020-12-18T09:23:51.743+00:00

    Yes, it should work just fine, assuming you have a column called "Users" in your CSV file.

    0 comments No comments