{"id":2729,"date":"2019-04-26T15:28:57","date_gmt":"2019-04-26T13:28:57","guid":{"rendered":"https:\/\/www.itidea.nl\/?p=2729"},"modified":"2019-04-26T15:32:53","modified_gmt":"2019-04-26T13:32:53","slug":"how-to-manage-allow-access-requests-with-powershell","status":"publish","type":"post","link":"https:\/\/www.itidea.nl\/index.php\/how-to-manage-allow-access-requests-with-powershell\/","title":{"rendered":"How to manage &#8216;Allow access requests&#8217; with PowerShell"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In SharePoint access requests to the current web can be managed.<br>Go to Site Settings; Site Permissions; and select &#8216;Access Request Settings&#8217; in the ribbon.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"223\" height=\"136\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/1-Ribbon-Manage-Allow-access-requests.png\" alt=\"\" class=\"wp-image-2733\"\/><figcaption>Figure 1 &#8211; &#8216;Access Request Settings&#8217; in the ribbon<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The screen in figure 2 is then shown allowing you to manage the settings.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"492\" height=\"300\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/2-Manage-Allow-access-requests.png\" alt=\"\" class=\"wp-image-2732\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/2-Manage-Allow-access-requests.png 492w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/2-Manage-Allow-access-requests-300x183.png 300w\" sizes=\"auto, (max-width: 492px) 100vw, 492px\" \/><figcaption>Figure 2 &#8211; Mange the access requests<br><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">My main concern here is to manage the checkbox &#8216;Allow access requests&#8217; with PowerShell.<br>Below that checkbox there are two options:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The owner group <\/li><li>An email address<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Disable access requests<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To clear the\ncheckbox when an email address is selected set the RequestAccessEmail property\nof the web to an empty string. This clears the email address in the box and\ndeselects the checkbox.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When the\ngroup is selected the procedure is quite different. To deselect the &#8216;Allow\naccess requests&#8217; checkbox the method SetUseAccessRequestDefaultAndUpdate of the\nweb object has to be used.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>You can set both options at a time to disable &#8216;Allow access requests&#8217; regardless of which setting is used in the web.<\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\n$web = Get-PnPWeb\n# When an emailaddress is selected, empty it to disable the setting\n$web.RequestAccessEmail = &quot;&quot;\n# When the first radiobutton, group, is selected, setting it \n# to false disables the setting\n$web.SetUseAccessRequestDefaultAndUpdate($false)\n$web.Update()\n$web.Context.ExecuteQuery()\n<\/pre><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"492\" height=\"294\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/3-Disable-Allow-access-requests.png\" alt=\"\" class=\"wp-image-2731\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/3-Disable-Allow-access-requests.png 492w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/3-Disable-Allow-access-requests-300x179.png 300w\" sizes=\"auto, (max-width: 492px) 100vw, 492px\" \/><figcaption>Figure 3 &#8211; Disable access requests<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Enable access requests<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To enable access requests by group or email address and provide a custom message to users who see the access request page, the following code can be used to set the group:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\n$web = Get-PnPWeb\n# Set the group option to true to enable the setting\n$web.SetUseAccessRequestDefaultAndUpdate($true)\n# Set a message\n$web.SetAccessRequestSiteDescriptionAndUpdate(&quot;Welcome to this page (group)&quot;)\n$web.Update()\n$web.Context.ExecuteQuery()\n<\/pre><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"492\" height=\"300\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/4-Enable-Allow-access-requests-group.png\" alt=\"\" class=\"wp-image-2730\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/4-Enable-Allow-access-requests-group.png 492w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/4-Enable-Allow-access-requests-group-300x183.png 300w\" sizes=\"auto, (max-width: 492px) 100vw, 492px\" \/><figcaption>Figure 4 &#8211; Enable access requests group<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"613\" height=\"185\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/5-Enable-Allow-access-requests-group-message-1.png\" alt=\"\" class=\"wp-image-2758\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/5-Enable-Allow-access-requests-group-message-1.png 613w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/5-Enable-Allow-access-requests-group-message-1-300x91.png 300w\" sizes=\"auto, (max-width: 613px) 100vw, 613px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Use the following code to set the email address:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\n$web = Get-PnPWeb\n# Fill the emailaddress and set the group option to false\n$web.SetUseAccessRequestDefaultAndUpdate($false)\n$web.RequestAccessEmail = &quot;a@b.nl&quot;\n# Set a message\n$web.SetAccessRequestSiteDescriptionAndUpdate(&quot;Welcome to this page (email address)&quot;)\n$web.Update()\n$web.Context.ExecuteQuery()\n<\/pre><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"468\" height=\"295\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/6-Enable-Allow-access-requests-email.png\" alt=\"\" class=\"wp-image-2735\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/6-Enable-Allow-access-requests-email.png 468w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/6-Enable-Allow-access-requests-email-300x189.png 300w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><figcaption>Figure 6 &#8211; Enable access requests email address<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"617\" height=\"197\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/7-Enable-Allow-access-requests-email-message-1.png\" alt=\"\" class=\"wp-image-2757\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/7-Enable-Allow-access-requests-email-message-1.png 617w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/04\/7-Enable-Allow-access-requests-email-message-1-300x96.png 300w\" sizes=\"auto, (max-width: 617px) 100vw, 617px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Summary<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To manage\naccess request settings requires just to check or uncheck one checkbox in the\nUI. After enabling it the group or email address can be selected and a custom\nmessage can be filled in.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When\nmanaging this setting using PowerShell you actually manage the group or email\naddress (and the custom message) and thereby indirectly the checkbox.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In SharePoint access requests to the current web can be managed.Go to Site Settings; Site Permissions; and select &#8216;Access Request Settings&#8217; in the ribbon. The screen in figure 2 is then shown allowing you to manage the settings. My main &#8230; <a class=\"more-link\" href=\"https:\/\/www.itidea.nl\/index.php\/how-to-manage-allow-access-requests-with-powershell\/\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,22,41],"tags":[37,43,46],"class_list":["post-2729","post","type-post","status-publish","format-standard","hentry","category-office-365","category-powershell","category-sharepoint","tag-office365","tag-powershell","tag-sharepoint"],"_links":{"self":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2729","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/comments?post=2729"}],"version-history":[{"count":22,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2729\/revisions"}],"predecessor-version":[{"id":2779,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2729\/revisions\/2779"}],"wp:attachment":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/media?parent=2729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/categories?post=2729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/tags?post=2729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}