Hello Friends.
Welcome back with another post on Power Automate. Today, we will learn about How to get users from Azure Active Directory Group through Power Automate. Sometimes, there are the requirements that we need to send mails to some users that belongs to a particular AD group. Therefore, our approach will first to get all the users from that AD group and then perform activity (like sending email) as per the application requirement. Let's start.
- Create a blank "Instant cloud flow" with trigger as "Manually trigger a flow". Give it a name - ExtractADGroupUsers.
- Now, we need the ID of that AD Group for which, users need to extract. You may ask this ID either from the AD Admin or you can add that group in your SharePoint site and then click on that group, it's account filed will give you the ID of that group. The GUID after the "tenant|" is the ID of the group.
- Now, go back to the flow and add an action "List group members" under "Office 365 Groups" category.
- It will ask the Group ID. Input the ID we had copied from SharePoint discussed above.
- Save it and Test it.
- It will give us a JSON of all the users belong to this group. The attribute, which is important for us is "mail" and then "displayname". The primary is "mail".
- Now, edit the flow again and initialize an array, in which you need to store the Email IDs.
- Now, we need to use an "Apply to each" action to capture the EmailIDs and store in array. During this process, we will also check that EMail ID must not be null.
- That's all.
- If you wish to see, what all email ids have been captured, you may initialize another array and assign it with arrayGroupUserEMails array.
- Now Test the flow.
- As you can see from above screenshots, the flow ran successfully and we have extracted users belongs to the group.
- This is the shortest and straight way to perform the activity.
- However, there can be other ways as well to perform the same activity like-
- First- use the Select action to get the Emails only
- Then use "Apply to each" action to add emails in array.
- Second- use the "Filter" action to filter out null emails items.
- Then use "Apply to each" action to add emails in array.
- However, the results would remain same in all the cases.
With this, I am concluding this post.
Happy Coding !!!
Will see you again with some new topics.
Stay Safe !
Stay Healthy !
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.