How to manage ‘Allow access requests’ with PowerShell

26 Apr

In SharePoint access requests to the current web can be managed.
Go to Site Settings; Site Permissions; and select ‘Access Request Settings’ in the ribbon.

Figure 1 – ‘Access Request Settings’ in the ribbon

The screen in figure 2 is then shown allowing you to manage the settings.

Figure 2 – Mange the access requests

My main concern here is to manage the checkbox ‘Allow access requests’ with PowerShell.
Below that checkbox there are two options:

  • The owner group
  • An email address

Disable access requests

To clear the checkbox when an email address is selected set the RequestAccessEmail property of the web to an empty string. This clears the email address in the box and deselects the checkbox.

When the group is selected the procedure is quite different. To deselect the ‘Allow access requests’ checkbox the method SetUseAccessRequestDefaultAndUpdate of the web object has to be used.

You can set both options at a time to disable ‘Allow access requests’ regardless of which setting is used in the web.

$web = Get-PnPWeb
# When an emailaddress is selected, empty it to disable the setting
$web.RequestAccessEmail = ""
# When the first radiobutton, group, is selected, setting it 
# to false disables the setting

Figure 3 – Disable access requests

Enable access requests

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:

$web = Get-PnPWeb
# Set the group option to true to enable the setting
# Set a message
$web.SetAccessRequestSiteDescriptionAndUpdate("Welcome to this page (group)")

Figure 4 – Enable access requests group

Use the following code to set the email address:

$web = Get-PnPWeb
# Fill the emailaddress and set the group option to false
$web.RequestAccessEmail = ""
# Set a message
$web.SetAccessRequestSiteDescriptionAndUpdate("Welcome to this page (email address)")

Figure 6 – Enable access requests email address


To manage access request settings requires just to check or uncheck one checkbox in the UI. After enabling it the group or email address can be selected and a custom message can be filled in.

When managing this setting using PowerShell you actually manage the group or email address (and the custom message) and thereby indirectly the checkbox.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.