Forum Discussion
Allow access request setting
Is there a way to disable the Allow access request setting?
I’ve had a try using the null $web.RequestAccessEmail approach, but the option is still enabled with the Site Owners group selected instead.
Anyway to turn it off using PnP or CSOM?
Thanks
Hi Steve Johnson, try this (works in my tenancy):
Connect-PnPOnline -Url <site collection url>
$web = Get-PnPWeb
$web.RequestAccessEmail = ""
$web.Update()
Invoke-PnPQuery
- Oliver ZeiserBrass ContributorSetting it to string.Empty should work. PnP Core has an extension for it. web.DisableRequestAccess()
- Matt WestonIron Contributor
Hi Steve Johnson, are you referring to the request form for users to complete if they don't have access?
If so, you can do this through the user interface.
On modern sites:
- Click on the Settings Cog, and select Site Permissions.
- Once the Site Permissions pop out is on the screen, select "Advanced permissions settings"
- You will then see a classic page with the ribbon at the top. In the "Manage" group, click "Access Request Settings"
- Untick the option "Allow access requests"
I hope that helps
- Steve JohnsonCopper Contributor
Thanks guys! Sorry Matt Weston, I should've specified that I have a whole bunch of Site Collections affected and it's causing confusion for users, so I'm looking at switching it off and adjusting our provisioning solution as appropriate too.
Oliver Zeiser Thanks, I've tried what you've suggested, but the Allow access requests box is refusing to uncheck.
This is the code I'm running - am I missing anything do you know?
$web = Get-PnPWeb -Includes MembersCanShare, AssociatedMemberGroup.AllowMembersEditMembership
$web.MembersCanShare=$false
$web.AssociatedMemberGroup.AllowMembersEditMembership=$false
$web.RequestAccessEmail=""
$web.AssociatedMemberGroup.Update()
$web.Update()
$web.Context.ExecuteQuery()
Write-Host "Access request settings updated" - Matt WestonIron Contributor
Hi Steve Johnson, try this (works in my tenancy):
Connect-PnPOnline -Url <site collection url>
$web = Get-PnPWeb
$web.RequestAccessEmail = ""
$web.Update()
Invoke-PnPQuery- Steve JohnsonCopper ContributorHuge thanks for that Matt, that works! Although the test site collection I was using, it refused to work on, but on my others, it was fine. Weird.