1

I am trying to disable access request using PowerShell CSOM. But when i try to set RequestAccessEmail to "", it does not work if the first radio button is checked. It will work only if the second radio button is checked.

enter image description here

0

here is the script:

$SiteUrl = "https://<TenantName>.sharepoint.com/sites/<Sitename>"  
$UserName = "admin@<TenantName>..onmicrosoft.com"  
$Password ="password"
$loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") 
$loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
$loadInfo3 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.UserProfiles")
#$sstr = ConvertTo-SecureString -string $AdminPass -AsPlainText -Force
$Securepass = ConvertTo-SecureString $Password -AsPlainText -Force
$context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,$Securepass)
$Web = $context.Web
$AllProperties=$Web.AllProperties
$context.Load($Web)
$context.Load($AllProperties)
$context.ExecuteQuery()
$Web.MembersCanShare=$false
$web.Update();
$web.Context.ExecuteQuery()
$AssociatedMember=$web.AssociatedMemberGroup
$context.Load($AssociatedMember)
$context.ExecuteQuery()
$web.AssociatedMemberGroup.AllowMembersEditMembership = $false
$web.AssociatedMemberGroup.Update();
$web.Context.ExecuteQuery() 

You need to install CSOM module Version 16.1.4727.1200 and above to use this.

Hope it helps!

  • This approach doesnt work, have to tried this scenario, where the radio button is defaulted to the Owners group and you are disabling the access request – dsouzajoel22 Mar 13 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.