Access request settings:
To configure access request email settings in SharePoint online, Go to
Configure SharePoint online access request settings using PowerShell
Use this PowerShell script to update SharePoint online access request email.
Disable access request in SharePoint online:
To disable access request, simply clear the Email value!
To configure access request email settings in SharePoint online, Go to
- Site Settings >> Site Permissions >> Access Requests Settings
- This takes you to SharePoint online access request page >> Update access request email and hit OK to save your changes.
Configure SharePoint online access request settings using PowerShell
Use this PowerShell script to update 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()
#Set Access request Email
$Web.RequestAccessEmail =$AccessReqEmail
#Member settings
$Web.MembersCanShare = $True
$web.AssociatedMemberGroup.AllowMembersEditMembership = $True
$web.AssociatedMemberGroup.Update()
$Web.Update()
$Ctx.ExecuteQuery()
}
Catch {
write-host -f Red "Error configuring Access request settings!" $_.Exception.Message
}
Disable access request in SharePoint online:
To disable 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
#disable Access request
$Web = $Ctx.Web
$Web.RequestAccessEmail = ""
$Web.MembersCanShare = $False
$web.AssociatedMemberGroup.AllowMembersEditMembership = $False
$web.AssociatedMemberGroup.Update()
$Web.Update()
$Ctx.ExecuteQuery()
}
Catch {
write-host -f Red "Error disabling Access request settings!" $_.Exception.Message
}