web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Remove user from all D...
Power Automate
Suggested Answer

Remove user from all Distribution lists

(1) ShareShare
ReportReport
Posted on by 10
How do I remove a user from all Distribution lists with Power Automate? I've tried the Entra Remove member from group, Office 365 Remove member from group, and Send an HTTP request actions. I can get any of those options to remove all the groups from a user except for Distribution lists.
Categories:
I have the same question (1)
  • Suggested answer
    Riyaz_riz11 Profile Picture
    4,150 Super User 2026 Season 1 on at
    Hi,
     
    Recommended Solution: Use Power Automate + Azure Automation + Exchange Online PowerShell
     Step-by-Step Setup
     1. Create an Azure Automation Account
    If not already created:
    Go to Azure Portal → Automation Accounts → Create
     2. Import ExchangeOnlineManagement Module
    In your Automation Account:
    Go to Modules → Browse Gallery
    Search for ExchangeOnlineManagement
    Import it
     3. Create a Runbook (PowerShell)
    In the Automation Account:
    Go to Runbooks → Create a Runbook
    Name: RemoveUserFromDLs
    Type: PowerShell
    Paste the script below
    PowerShell Script for Runbook:
    param (
        [string]$UserPrincipalName
    )
    # Connect to Exchange Online
    Connect-ExchangeOnline -ManagedIdentity
    # Get all distribution groups the user is a member of
    $DLs = Get-DistributionGroup | Where-Object {
        Get-DistributionGroupMember -Identity $_.Identity -ResultSize Unlimited | Where-Object {$_.PrimarySmtpAddress -eq $UserPrincipalName}
    }
    # Remove user from each DL
    foreach ($dl in $DLs) {
        Remove-DistributionGroupMember -Identity $dl.Identity -Member $UserPrincipalName -Confirm:$false
    }

     Important: You can also use certificate-based authentication or managed identity instead of prompting for credentials.
     4. Trigger the Runbook from Power Automate
    In Power Automate:
    Use "Create job" action from Azure Automation
    Resource Group
    Automation Account
    Runbook Name: RemoveUserFromDLs
    Parameters:
    {
      "UserPrincipalName": "user@domain.com"
    }

     
     
    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz
  • Brian987 Profile Picture
    10 on at
    @Riyaz_riz11 After some research, I found that what you are talking about requires a pay-as-you-go pricing plan, which would not work for this company.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 784

#2
Valantis Profile Picture

Valantis 581

#3
Haque Profile Picture

Haque 545

Last 30 days Overall leaderboard