Remove DL members

Glenn Maxwell 10,551 Reputation points

Hi All

i have users list in csv file, i want to remove users from the DL, will the below syntax help me.
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.
610 questions
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,078 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,322 questions
0 comments No comments
{count} votes

Accepted answer
  1. ChelseaWu-MSFT 6,316 Reputation points

    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 -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 98,681 Reputation points MVP

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

    0 comments No comments