Are you looking to add members or list members of an exchange email distribution list via Power Automate? As part of an onboarding process, maybe you have a Power App or Microsoft Form that allows a manager to request that their new member of staff is automatically added to one of many organisation wide or team distributions lists. Using a single action, this is easily achieved.
**Update January 2023**
I’ve written a new bog post detailing how this can be achieved with PowerShell and an Azure Runbook. Check it out here Add user to Distribution List – DamoBird365
**Update November 2021**
Whilst it is still possible to list group members of a Distribution or Mail Enabled Security Group, changes have been made to the Add member to Group Action, preventing members from being added. This was highlighted in recent comments. I will continue to monitor the situation and if things change or I become aware of another method, I will update this post to reflect how. Note the error received is “Cannot Update a mail-enabled security groups and or distribution list.” and has been commented on as a bug but now confirmed as an intended feature, here.
-END OF UPDATE-
First of all, you must know your Exchange Distribution List ID. This can be achieved by navigating to Exchange Admin Center, selecting Recipients, Groups, and selecting your Distribution Group. In the example below I have chosen my “Test Distro Group” and highlighted the Group ID in the URL. Please note that this process applies to Security Groups too, albeit the ID must be obtained from Azure Active Directory.
Now all you have to do is fire up Power Automate, choose your trigger, and click on the next step, then search for “Add member to group”. This action will allow you to supply the ID from above via “Enter custom value” and then all you have to supply is the User Principal Name, which is basically the user’s email.
Run your flow and that is all there is to it! You can now set up your Microsoft Form or Power App with a list of Distributions lists and your managers or users can request that they are added to distribution lists without the need for IT to be involved.
Retrieving a list of users in a Distribution List or Security Group
Ok, now that you have added a user, what if you want to check to see if a user already exists in the distribution list? Using the List Group Members action and the guid from before, we are able to obtain an array of users, including Display Name, Email, Job Title and a few other items. Now if we want to check that a user exists, using the email that I have manually provided in a compose (albeit you might want to take an email dynamically from a form submission or other means) we can perform a filter array action (note that I convert both strings tolower() as string comparisons are case sensitive). Using the Length() expression on the filter array, we are able to check if there is more than 0 results or maybe you would prefer to check the result equals 1? Either way, the outcome would be yes and you therefore know that the email already exists in the distribution list.
User Emails as an Array or List for Approvals or Sending an Email?
If you are just looking for an array of emails to use in an apply to each loop, or maybe a list of emails for an approval process, you can use a select action to create your array, or the results of the array with a join() to create your semi colon-separated list.
The output of both actions would appear like so:
Don’t forget – this works just as well on an Azure AD Security Group!
This does NOT work for Microsoft 365 Distribution lists (a single email address for a group of users), as mail-enabled security groups and or distribution lists are not currently supported through Power Automate.
Hi John, is this based on documentation or testing? I have used this in flows and it works, unless it has changed recently? What were your findings?
The response you get when doing this for a mail-enabled security group is:
“Cannot Update a mail-enabled security groups and or distribution list.”
Also on this page: https://docs.microsoft.com/en-au/azure/active-directory/fundamentals/active-directory-manage-groups
It states: “Other group types such as distribution lists and mail-enabled security groups are managed only in Exchange admin center or Microsoft 365 admin center. You must sign in to Exchange admin center or Microsoft 365 admin center to manage these groups.”
And on this page: https://docs.microsoft.com/en-us/graph/api/group-post-members?view=graph-rest-1.0&tabs=http
“You cannot use this API to add members to a mail-security security group.”
Seems it was a “bug” that allowed it to work, but recently changed: https://github.com/microsoftgraph/microsoft-graph-docs/issues/14899
Good shout – thanks for looking in to it. I have had a quick test on my tenant this morning and agree, I am getting the same error. It seems to have stopped 20th October. I’ll update the blog post but also highlight this on the Microsoft forum. It seems like a strange decision to remove this as a bug when there would be a good use case for it.
Sorry for the late response. My finding was based on testing. I see that Loryan has correctly specified the error returned by the flow when attempting to do this with a mail-enabled group.
Is there any workaround to this crazy decision from Microsoft ? How can someone manage automatically the members inside a mail enabled Azure Active Directory or Distribution list?
Which trigger did you use?
Trigger is down to your use case? Where is the data coming from, what do you want this flow to start from?
So that explains why my flows are failing now! That’s one bug I wish they hadn’t ‘Fixed’
Sorry Dan, I hope the article helped identify your problem at least. If things change and I am made aware, I will update the blog to reflect this change. Seems like an in demand feature though.
Can this pattern be used to populate using a contact’s username ?
Can I create a Distribution List by Power Automate?
In theory you could use https://learn.microsoft.com/en-us/powershell/module/exchange/new-distributiongroup?source=recommendations&view=exchange-ps and an automation account but I’ve not tried this myself, if you do manage to set it up, please let me know.
Thanks 🙂
Add members for email enabled group it gives error Insufficient privileges to complete the operation. I am the owner for this group still its throwing error.
Unfortunately I do not know what the cause could be and can only suggest you try a forum.