PowerShell script to set user email in the access request settings on Modern SharePoint Site

Technology Specialist
Published On :   08 Nov 2018
Visit Count
Today :  1    Total :   314

In this article, let us see how to change or add the user to access request list

The access request feature allows people to request access to content that they do not currently have permission to see. As a site owner, you can configure the feature to send you mail when someone requests access to a site. You can then choose whether to approve or decline their request. If you approve the request, you can also specify the specific level of permission you’d like to assign to a user.

 #Load SharePoint CSOM Assemblies
 #Set Variables for Site URL
 $SiteURL= "https://xxx.sharepoint.com/sites/xxx/"
 #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
 #Set Access request Email
 $Web.RequestAccessEmail =$AccessReqEmail
 #Member settings
 $Web.MembersCanShare = $True
 $web.AssociatedMemberGroup.AllowMembersEditMembership = $False
 Write-Host "Access Request Settings applied"
 Catch {

Hope this helps!