Remove User from all SharePoint Groups with Power Automate
In this article I will describe how to use Power Automate in order to remove a user from all SharePoint Groups of a specific site, the user is member of.
All actions for doing this:
- Get UserId of user from Mail
- Get Groups of the user
- Remove the user
Starting point is the mail address of the specific user. You can think about using PowerApps Trigger and pass a mail within the parameter, use a manually trigger or…. It is up to you 😉 at the end we just need the Mail address.
Get UserId of user
Simple SharePoint HTTP call is doing this job. We store the id of the output into a variable.
Get Groups of the user
Now just safe the flow and run a test to get the output body of the HTTP call.This should be used to parse the json (Generate by sample, the sample in that case is the body). Step by step:
- Run a test
- Copy the output (body)
- Edit flow
- Insert parse json action
- Click on button Generate from sample
- Paste body here
- You can use the variables 😉
We need the iterate though all group IDs and store it in an array.
Remove the user
Last step is to simply iterate through all elements of the array and remove the user with a SharePoint HTTP call.