SharePoint Online: Configure Access Requests Settings using PowerShell

Access Request Settings in SharePoint Online
The access request feature in SharePoint Online allows people to request access to the content they do not have permission to access. It also allows members of the site to send invitations to users who have no permission. Once the invitations are sent, the Site owner should approve them from Site settings >> Access requests and invitations. If you change these settings on the Site Collection level, then new subsites don’t inherit.

How to Set SharePoint Online Access Request Email?

To configure access request email settings in SharePoint Online, Go to:

sharepoint online access requests settings

  1. Site Settings >> Site Permissions >> Access Requests Settings.
  2. This takes you to the SharePoint Online access request page >> Update access request email and hit OK to save your changes.

Similarly, on group-connected sites, You can set the access requests by going to Settings >> Site Permissions >> Click on “Change how members can share” >> Turn on the “Allow Access requests” and configure who will receive access requests for the site.

sharepoint online powershell set access request email

Please note, SharePoint Online access request email Site Settings must be configured at each site level. Let’s see SharePoint Online PowerShell to set access request email.

If a site is inhering permissions from its parent site, Access request settings also inherited! In other words, you can set access request settings for sites with unique permissions only!

Set SharePoint Online access request settings using PowerShell

Use this PowerShell script to update the SharePoint Online access request email.

#Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" #Set Variables for Site URL $SiteURL= "https://crescent.sharepoint.com/sites/sales/" $AccessReqEmail="SharePointSupport@crescent.com" #Setup Credentials to connect $Cred = Get-Credential $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password) Try < #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Cred #Get the current settings $Web = $Ctx.Web $Ctx.Load($web.AllProperties) $web.RequestAccessEmail $Ctx.ExecuteQuery() #sharepoint online powershell set access request email $Web.RequestAccessEmail =$AccessReqEmail #Member settings $Web.MembersCanShare = $True $web.AssociatedMemberGroup.AllowMembersEditMembership = $True $web.AssociatedMemberGroup.Update() $Web.Update() $Ctx.ExecuteQuery() >Catch

This sets SharePoint Online access request settings with PowerShell.

Disable Access Requests in SharePoint Online using PowerShell:

To disable the access request, simply clear the Email value!

#Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" #Set Variables for Site URL $SiteURL= "https://crescent.sharepoint.com/sites/sales/" #Setup Credentials to connect $Cred = Get-Credential $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password) Try < #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Cred #sharepoint online disable access request powershell $Web = $Ctx.Web $Web.RequestAccessEmail = [string]::Empty $Web.MembersCanShare = $False $web.AssociatedMemberGroup.AllowMembersEditMembership = $False $web.AssociatedMemberGroup.Update() $Web.Update() $Ctx.ExecuteQuery() >Catch

To change access request Emails of all sites in a site collection or tenant use: SharePoint Online: PowerShell to Change Access Request Email for All Sites

SharePoint Online: Disable Access Request using PnP PowerShell

#Set Variables $SiteURL = "https://crescent.sharepoint.com/sites/Marketing" #Connect to PnP Online Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential) #Get the Web $Web = Get-PnPWeb #sharepoint online powershell disable access requests $Web.RequestAccessEmail = [string]::Empty $Web.SetUseAccessRequestDefaultAndUpdate($False) $Web.Update() $Web.Context.ExecuteQuery()

This PowerShell script clears both the Access Request Email and Group Settings! Similarly, to disable access requests for all sites in the tenant, use: SharePoint Online: Disable Access Requests for All Sites using PowerShell

Enable access requests to the owner group of the site using PnP PowerShell:

To set access requests to the site owners, use:

#Set Variables $SiteURL = "https://crescent.sharepoint.com/sites/Marketing" #Connect to PnP Online Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential) #Get the Web $Web = Get-PnPWeb #Enable Access Request for the site to the Owners Group $Web.SetUseAccessRequestDefaultAndUpdate($True) $Web.Update() $Web.Context.ExecuteQuery()

Similarly, to set Emails in the access request, use the PnP PowerShell cmdlet Set-PnPRequestAccessEmails:

Connect-PnPOnline -Url https://crescent.sharepoint.com/sites/marketing -Interactive #Update Access Request Email Set-PnPRequestAccessEmails -Emails @("Admin@crescent.com", "SPAdmin@crescent.com")

sharepoint online powershell set access request email

To change the access request email in SharePoint Online, use the following:

#Enable Access Request for the site to a Email ID $Web.RequestAccessEmail = "Someone@YourDomain.com" $Web.SetUseAccessRequestDefaultAndUpdate($False) $Web.Update() $Web.Context.ExecuteQuery()

Last but not least: Are access requests and invitations missing in SharePoint Online? Well, that’s because – Access request settings are disabled!