Remove DL members

Glenn Maxwell 11,496 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.
650 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,837 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,585 questions
0 comments No comments
{count} votes

Accepted answer
  1. ChelseaWu-MSFT 6,326 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 108.2K 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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.