{"id":146,"date":"2022-04-18T09:18:47","date_gmt":"2022-04-18T08:18:47","guid":{"rendered":"https:\/\/m365-blog.de\/?p=146"},"modified":"2022-04-18T09:32:11","modified_gmt":"2022-04-18T08:32:11","slug":"remove-user-from-all-sharepoint-groups-with-power-automate","status":"publish","type":"post","link":"https:\/\/m365-blog.de\/?p=146","title":{"rendered":"Remove User from all SharePoint Groups with Power Automate"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<p>All actions for doing this:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Get UserId of user from Mail<\/li><li>Get Groups of the user<\/li><li>Remove the user<\/li><\/ul>\n\n\n\n<p>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\u2026. It is up to you \ud83d\ude09 at the end we just need the Mail address.&nbsp;<\/p>\n\n\n\n<p><strong>Get UserId of user<\/strong><\/p>\n\n\n\n<p>Simple SharePoint HTTP call is doing this job. We store the id of the output into a variable.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"814\" src=\"https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.27-1024x814.jpg\" alt=\"\" class=\"wp-image-152\" srcset=\"https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.27-1024x814.jpg 1024w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.27-300x238.jpg 300w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.27-768x610.jpg 768w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.27.jpg 1236w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Call: _api\/web\/SiteUsers\/getByEmail(&#8216;@{variables(&#8216;mail&#8217;)}&#8217;)<\/p>\n\n\n\n<p><strong>Get Groups of the user<\/strong><\/p>\n\n\n\n<p>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:&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Run a test<\/li><li>Copy the output (body)<\/li><li>Edit flow&nbsp;<\/li><li>Insert parse json action&nbsp;<\/li><li>Click on button Generate from sample<\/li><li>Paste body here&nbsp;<\/li><li>Save<\/li><li>Test&nbsp;<\/li><li>You can use the variables \ud83d\ude09<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>We need the iterate though all group IDs and store it in an array.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"456\" src=\"https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-1024x456.jpg\" alt=\"\" class=\"wp-image-153\" srcset=\"https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-1024x456.jpg 1024w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-300x134.jpg 300w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-768x342.jpg 768w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28.jpg 1244w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Call: _api\/web\/GetUserById(@{variables(&#8216;userid&#8217;)})\/Groups<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"811\" height=\"1024\" src=\"https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-1-811x1024.jpg\" alt=\"\" class=\"wp-image-154\" srcset=\"https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-1-811x1024.jpg 811w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-1-238x300.jpg 238w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-1-768x969.jpg 768w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-1-1217x1536.jpg 1217w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-1.jpg 1236w\" sizes=\"auto, (max-width: 811px) 100vw, 811px\" \/><\/figure>\n\n\n\n<p>Id: @{items(&#8216;Apply_to_each_Group_store_ID&#8217;)?[&#8216;Id&#8217;]}<\/p>\n\n\n\n<p><strong>Remove the user<\/strong><\/p>\n\n\n\n<p>Last step is to simply iterate through all elements of the array and remove the user with a SharePoint HTTP call.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"866\" src=\"https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-1024x866.jpg\" alt=\"\" class=\"wp-image-155\" srcset=\"https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-1024x866.jpg 1024w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-300x254.jpg 300w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-768x650.jpg 768w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2.jpg 1298w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Call: _api\/web\/sitegroups(@{items(&#8216;Apply_to_each&#8217;)})\/users\/RemoveByID(@{variables(&#8216;userid&#8217;)})<\/p>\n\n\n\n<p><strong>Example Flow&nbsp;<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"1024\" src=\"https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-3-695x1024.jpg\" alt=\"\" class=\"wp-image-156\" srcset=\"https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-3-695x1024.jpg 695w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-3-204x300.jpg 204w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-3-768x1131.jpg 768w, https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-3.jpg 1020w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>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 MailGet Groups of the userRemove the user Starting point is the mail address of the specific user. You can think [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":155,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[3,4,2],"tags":[17,13,12],"class_list":["post-146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-power-apps","category-power-automate","category-power-plattform","tag-powerapps","tag-powerautomate","tag-powerplatform"],"uagb_featured_image_src":{"full":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2.jpg",1298,1098,false],"thumbnail":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-150x150.jpg",150,150,true],"medium":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-300x254.jpg",300,254,true],"medium_large":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-768x650.jpg",640,542,true],"large":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-1024x866.jpg",640,541,true],"elegant_blocks_team_1":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-500x500.jpg",500,500,true],"elegant_blocks_blog_1":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-693x462.jpg",693,462,true],"elegant_blocks_slider_1":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-1298x1000.jpg",1298,1000,true],"1536x1536":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2.jpg",1298,1098,false],"2048x2048":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2.jpg",1298,1098,false],"bizberg_medium":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-300x300.jpg",300,300,true],"bizberg_gallery":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-500x400.jpg",500,400,true],"bizberg_blog_list":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-368x240.jpg",368,240,true],"bizberg_detail_image":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-825x400.jpg",825,400,true],"bizberg_detail_image_no_sidebar":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-920x400.jpg",920,400,true],"bizberg_portfolio_homepage":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-600x400.jpg",600,400,true],"bizberg_blog_list_no_sidebar_1":["https:\/\/m365-blog.de\/wp-content\/uploads\/2022\/04\/Image-18.04.22-at-10.28-2-220x190.jpg",220,190,true]},"uagb_author_info":{"display_name":"m365admin","author_link":"https:\/\/m365-blog.de\/?author=1"},"uagb_comment_info":25,"uagb_excerpt":"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 MailGet Groups of the userRemove the user Starting point is the mail address of the&hellip;","_links":{"self":[{"href":"https:\/\/m365-blog.de\/index.php?rest_route=\/wp\/v2\/posts\/146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/m365-blog.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/m365-blog.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/m365-blog.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/m365-blog.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=146"}],"version-history":[{"count":5,"href":"https:\/\/m365-blog.de\/index.php?rest_route=\/wp\/v2\/posts\/146\/revisions"}],"predecessor-version":[{"id":158,"href":"https:\/\/m365-blog.de\/index.php?rest_route=\/wp\/v2\/posts\/146\/revisions\/158"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/m365-blog.de\/index.php?rest_route=\/wp\/v2\/media\/155"}],"wp:attachment":[{"href":"https:\/\/m365-blog.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/m365-blog.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/m365-blog.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}