Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Using Power Automate to remove user from a SharePoint group

(0) ShareShare
ReportReport
Posted on by 544

Hi all,

I've successfully set up my flow to add users to a SharePoint group using the instructions from this post:

https://powerusers.microsoft.com/t5/Building-Flows/Adding-users-to-a-SharePoint-Group/td-p/309811

 

To remove a user from a group, I'm not quite following this solution:

https://powerusers.microsoft.com/t5/Connecting-To-Data/Use-Flow-to-Remove-User-from-Permissions-Group/td-p/184293

 

I'm looking at Microsoft's documentation:

https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn531432(v=office.15)

 

Here's a screenshot of my flow.  It's grabbing the user information in the previous step of Get User Profile, but it's falling down on the URI and body steps.  Help would be appreciated.  (I hate syntax.)

 

removeuserfromSPgroup.jpg

  • delicatebeing1 Profile Picture
    23 on at
    Re: Using Power Automate to remove user from a SharePoint group

    yeah, unfortunately, concept of for each really screws up and causes error for any loop and step that I create, which makes me spend x10 longer time for any loop design 😞

    i guess its modern

  • smorley Profile Picture
    544 on at
    Re: Using Power Automate to remove user from a SharePoint group

    Does this happen in the modern and classic version of Power Automate?

  • delicatebeing1 Profile Picture
    23 on at
    Re: Using Power Automate to remove user from a SharePoint group

    hi dear @Expiscornovus 

     

    I am dealing with same issue as original poster,

    the issue is once I define a dynamic value from a sharepoint list item(giving info on a user to be picked up) as user for upn entry, a new "for each parent" is automatically generated, which screws up with initialize variable and leading to errors. What would you suggest?

    delicatebeing1_0-1718208495818.png

     

     

  • smorley Profile Picture
    544 on at
    Re: Using Power Automate to remove user from a SharePoint group

    @Expiscornovus FANTASTIC!!!!!!!!!!  THANK YOU SO MUCH!

  • Verified answer
    Expiscornovus Profile Picture
    32,131 Most Valuable Professional on at
    Re: Using Power Automate to remove user from a SharePoint group

    Hi @smorley,


    I see in the screenshot you are using a principalname value. Like mentioned in my previous reply, the loginname value will be slightly different. That is why it can't find your user.

     

    A quick fix could be to concatenate the userPrincipal name with 'i:0#.f|membership|':

    This example assumes your action before it is a Get User Profile (V2) (which you haven't renamed 😁) and that the user you are using in this test is an internal user and not a guest user (part of the tenant).

     

    concat('i:0#.f|membership|',outputs('Get_user_profile_(V2)')?['body/userPrincipalName'])

     

    concat_upn_withclaim.png

     

  • smorley Profile Picture
    544 on at
    Re: Using Power Automate to remove user from a SharePoint group

    @Expiscornovus Definitely making some headway.

     

    I've updated the action to reflect the changes you suggested.

    smorley_0-1646152296847.png

    The error message I get is: 

    {"odata.error":{"code":"-2130575276, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The user does not exist or is not unique."}}}
    clientRequestId: 6ae24fea-75c3-4c7a-b7fd-d1478b8f2184
    serviceRequestId: fa8725a0-5061-1000-61dd-bbc02083e781

    The error is referring to the body statement:

    smorley_1-1646152375113.png

     

     

  • Expiscornovus Profile Picture
    32,131 Most Valuable Professional on at
    Re: Using Power Automate to remove user from a SharePoint group

    Hi @smorley,

     

    This method expects the loginName. A loginName field in SharePoint Online typically has something like: i:0#.f|membership|janedoe@contoso.onmicrosoft.com which is not the UPN. You probably need to change that in your string variable.

     

    The Send an HTTP request to SharePoint action also needs some changes. First of all you want to use a POST method. I would also change the Accept header value. In the body I would also use the loginName property.

     

    Below is an example of that approach:

     

    removebyloginname_restapi.png

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1