“My organisation still uses SharePoint groups to manage permissions, can I automatically remove user from a group with Power Automate flow?”
If you’re working with SharePoint groups, Power Automate won’t give you much help. All the actions expect that you’ll use M365 groups, that the SharePoint groups are a thing of the past. But it’s not that easy to change the whole SharePoint concept to fit such expectation. You’ve been using SP groups for some time and you’ll keep doing so. The only question is… how?
You’ll need HTTP request
If there’s no dedicated action, you need an HTTP request. It was already explained in the previous articles on adding permissions to a SharePoint group and adding user to a SharePoint group, but that was only addition. Now it’s time to do also the opposite – remove users from a group.
To remove user from a group you’ll need two pieces of information – the SharePoint group id (from the first linked article), and the user id. Once you have both the ids, you can add them into an HTTP request sent to SharePoint.
Method: POST
Uri:
_api/web/siteGroups/getById(<groupId>)/users/getById(<userId>)
Header:
{
"X-HTTP-Method": "DELETE"
}
And that’s it, that’s one less user in the SharePoint group.
Summary
Every Power Automate automation involving SharePoint group must be done via HTTP request, no matter if you want to add, list or remove user(s). In this case it’ll be a combination of three HTTP requests. Firstly, get the SharePoint group id using the group name. Secondly, get the user id using his email. Once you have this information put the final HTTP request together and send it to the SharePoint.
How to get all groups from a user and remove the user from all groups?
Hello Everart,
I guess you’d have to list all groups everywhere and all members of these groups to find the user. I don’t think you can easily get a list of all groups per user, that’s why it’s better to use M365 groups instead of SP groups.
This removes my whole group, not the specified user! 🙁
Can you tell me what’s happening, cause I’ve tried this but it’s not working, only deleting my whole SP Group