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 / Removing user from an ...
Power Automate
Answered

Removing user from an azure group when you don't know which one they're in

(0) ShareShare
ReportReport
Posted on by

Hi Everyone,

 

I'm making a flow that is triggered when a user has to be removed, i'm however stuck on a piece where a user can be in 2 different groups but you don't know which one he's in.

Basically a user can be in group A or group B, so i'd need to check first in which group they are and then delete them from that group, but does anyone know how this would be possible? 

Categories:
  • Expiscornovus Profile Picture
    33,997 Most Valuable Professional on at

    Hi @Lumina,

     

    You can use an array with the two group ids. For each group you can list the group members and check if the user is part of it. After that you can remove them of the group, if needed (if the user isn't part of the group the remove member action will be skipped).

     

    Below is an example

     

    1. The filter array uses the below expression for the where statement

    @equals(item()?['mail'], outputs('Get_user_profile_(V2)')?['body/mail'])

     

    2. The group Id field uses the current item of the first apply to each

    items('Apply_to_each')

     

    filterarray_listgroupmembers.png

  • CU02080621-5 Profile Picture
    on at

    Hi,

     

    Thanks for the suggestion, I'm going to try this and i'll let you know if it works.

  • CU02080621-5 Profile Picture
    on at

    Hi,

    I tried this solution but it doesn't work, the user does not get removed from any of the 2 groups.

    It appears that it's limited to the amount of members it can get from the groups, I forgot to add these groups have hundreds of users in them.

    So my guess is that it's only getting x amount of users each time and thus missing the majority of them. Any ideas? 

  • Expiscornovus Profile Picture
    33,997 Most Valuable Professional on at

    Hi @Lumina,

     

    Thanks for letting me know that these are groups with a lot of members, that can be more challenging.

     

    In that case lets change the approach. You just want to check it for a single user at the time, correct?

     

    In that case you might want to use the List a user's direct memberships Graph API method:

    https://learn.microsoft.com/en-us/graph/api/user-list-memberof?view=graph-rest-1.0&tabs=http

     

    And/or the List a user's memberships (direct and transitive) method:

    https://learn.microsoft.com/en-us/graph/api/user-list-transitivememberof?view=graph-rest-1.0&tabs=http

     

  • Verified answer
    CU02080621-5 Profile Picture
    on at

    Hi,

    I also fixed it by enabling the pagination option of the get users in groups option and setting it to 2500.

     

    Your way might also work, just wanted to let people know this might also be an option if you're environment isn't too big.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 331 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard