Changing the "Allow members to share" SharePoint site Access Requests setting using Office Dev PnP

%3CLINGO-SUB%20id%3D%22lingo-sub-18562%22%20slang%3D%22en-US%22%3EChanging%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Office%20Dev%20PnP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-18562%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20can%20I%20set%20the%20%22Allow%20members%20to%20share%20the%20site%20and%20individual%20files%20and%20folders%22%20setting%20using%20the%20Office%20Dev%20PnP%20Provisioning%20Engine%20or%20PowerShell%20commands%3F%20I%20haven't%20found%20this%20specific%20setting%20in%20the%20commands.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20mean%20changing%26nbsp%3Bthe%20following%20setting(s)%20by%20PowerShell%20%2F%20remote%20provisioning%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F5615iEABD3663387B7796%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Access%20Requests%20Allow%20members%20to%20share.png%22%20title%3D%22Access%20Requests%20Allow%20members%20to%20share.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-276511%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-276511%22%20slang%3D%22en-US%22%3E%3CP%3EI%20ran%20into%20this%20same%20problem.%20Try%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24web%20%3D%20Get-PnPWeb%20-Includes%20MembersCanShare%2C%20AssociatedMemberGroup.AllowMembersEditMembership%3C%2FP%3E%3CP%3E%24web.MembersCanShare%3D%24false%3C%2FP%3E%3CP%3E%24web.AssociatedMemberGroup.AllowMembersEditMembership%3D%24false%3C%2FP%3E%3CP%3E%24web.AssociatedMemberGroup.Update()%3C%2FP%3E%3CP%3E%24web.RequestAccessEmail%20%3D%20%24null%3C%2FP%3E%3CP%3E%24web.Update()%3C%2FP%3E%3CP%3E%24web.Context.ExecuteQuery()%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-211701%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-211701%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F161570%22%20target%3D%22_blank%22%3E%40Mani%20Mehrabi%3C%2FA%3E%26nbsp%3BThanks!%20I%20have%20tried%20the%20suggested%20but%20it%20does%20not%20work.%20In%20the%20Access%20Request%20Settings%20it%20seems%20MS%20has%20also%20added%20a%20new%20radio%20button%20for%20choosing%20either%20email%20or%20the%20Site%20owners.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-211664%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-211664%22%20slang%3D%22en-US%22%3E%3CP%3EFor%20SharePoint%20online%20you%20can%20try%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConnect-PnPOnline%20-url%20%3CA%20href%3D%22https%3A%2F%2Fcontoso.sharepoint.com%2Fsites%2Ftest%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcontoso.sharepoint.com%2Fsites%2Ftest%3C%2FA%3E%3C%2FP%3E%3CP%3ESet-PnPRequestAccessEmails%20-Emails%20%22%20%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-173555%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-173555%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3EIs%20there%20also%20a%20command%20to%20enable%2Fdisable%20the%20%22Allow%20access%20requests%22%20via%20powsershell%3F%3C%2FP%3E%0A%3CP%3ECheers%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-128746%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-128746%22%20slang%3D%22en-US%22%3E%3CP%3EHeres%20the%20equivalent%20powershell.%20This%20works%20in%20O365%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%2300008b%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3Efunction%3C%2FFONT%3E%20%3CFONT%20color%3D%22%238a2be2%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EDisableMemberSharing%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E(%3C%2FFONT%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24siteUrl%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%20)%20%7B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%230000ff%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EConnect%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-Url%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24siteUrl%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24web%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%3D%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000ff%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EGet-PnPWeb%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-Includes%3C%2FFONT%3E%20%3CFONT%20color%3D%22%238a2be2%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EMembersCanShare%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%2C%3C%2FFONT%3E%20%3CFONT%20color%3D%22%238a2be2%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EAssociatedMemberGroup.AllowMembersEditMembership%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24web%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EMembersCanShare%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%3D%3C%2FFONT%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24false%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24web%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EAssociatedMemberGroup%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EAllowMembersEditMembership%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%3D%3C%2FFONT%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24false%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24web%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EAssociatedMemberGroup%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EUpdate()%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24web%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EUpdate()%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24web%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EContext%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EExecuteQuery()%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%E3%80%80%3C%2FP%3E%3CP%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-128728%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-128728%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3ESo%20there%20is%20no%20support%20for%20this%20in%20PNP-Powershell%20or%20the%20provisioning%20engine%20right%20now%3F%3C%2FP%3E%3CP%3ERussell%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-19325%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-19325%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Nigel%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Emy%20example%20could%20be%20used%20for%20both..%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKr%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPaul%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-19025%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-19025%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20this%20for%20SharePoint%20On-Line%20or%20SharePoint%20On-Premises%20%3F%20Or%20Both%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-18956%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-18956%22%20slang%3D%22en-US%22%3E%3CP%3EGreat%26nbsp%3Breplies%20of%20you%20all.%20Thanks!%20I'm%20sure%20I'll%20be%20able%20to%20generate%20a%20solution%20using%20your%20input%20next%20week.%20I'll%20update%20when%20I%20got%20it%20working.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-18951%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-18951%22%20slang%3D%22en-US%22%3E%3CP%3EI%20created%20a%20extention%20for%20that%3A%3C%2FP%3E%3CPRE%3E%20%20try%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Web%20rootweb%20%3D%20ctx.Site.RootWeb%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.Load(rootweb%2C%20w%20%3D%26gt%3B%20w.MembersCanShare)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.ExecuteQueryRetry()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20SharingConfiguration%20sharingSettings%20%3D%20configurationData.ToConfigObject%26lt%3BSharingConfiguration%26gt%3B()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20Set%20MembersCanShare%2C%20default%20to%20false%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rootweb.MembersCanShare%20%3D%20sharingSettings.Sharing.MembersCanShare%20%3F%20sharingSettings.Sharing.MembersCanShare%20%3A%20false%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rootweb.Update()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.Load(rootweb%2C%20w%20%3D%26gt%3B%20w.AssociatedMemberGroup.AllowMembersEditMembership)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.ExecuteQueryRetry()%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20Set%20AllowMembersEditMembership%2C%20default%20to%20false%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rootweb.AssociatedMemberGroup.AllowMembersEditMembership%20%3D%20sharingSettings.Sharing.AllowMembersEditMembership%20%3F%20sharingSettings.Sharing.AllowMembersEditMembership%20%3A%20false%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rootweb.AssociatedMemberGroup.Update()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.ExecuteQueryRetry()%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.Load(rootweb%2C%20w%20%3D%26gt%3B%20w.RequestAccessEmail)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.ExecuteQueryRetry()%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rootweb.RequestAccessEmail%20%3D%20sharingSettings.Sharing.RequestAccessEmail%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rootweb.Update()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.ExecuteQueryRetry()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20catch%20(Exception%20ex)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20TraceHelper.WriteErrorToListener(%22LogFile%22%2C%20ex.Message)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-18939%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-18939%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20can%20use%20this%20script.%20You%20need%20to%20install%20CSOM%20module%26nbsp%3BVersion%2016.1.4727.1200%20and%20above%20to%20use%20this.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%24SiteUrl%20%3D%20%22https%3A%2F%2F%26lt%3BTenantName%26gt%3B.sharepoint.com%2Fsites%2F%26lt%3BSitename%26gt%3B%22%20%20%0A%24UserName%20%3D%20%22admin%40%26lt%3BTenantName%26gt%3B..onmicrosoft.com%22%20%20%0A%24Password%20%3D%22password%22%0A%24loadInfo1%20%3D%20%5BSystem.Reflection.Assembly%5D%3A%3ALoadWithPartialName(%22Microsoft.SharePoint.Client%22)%20%0A%24loadInfo2%20%3D%20%5BSystem.Reflection.Assembly%5D%3A%3ALoadWithPartialName(%22Microsoft.SharePoint.Client.Runtime%22)%0A%24loadInfo3%20%3D%20%5BSystem.Reflection.Assembly%5D%3A%3ALoadWithPartialName(%22Microsoft.SharePoint.Client.UserProfiles%22)%0A%23%24sstr%20%3D%20ConvertTo-SecureString%20-string%20%24AdminPass%20-AsPlainText%20-Force%0A%24Securepass%20%3D%20ConvertTo-SecureString%20%24Password%20-AsPlainText%20-Force%0A%24context%20%3D%20New-Object%20Microsoft.SharePoint.Client.ClientContext(%24SiteUrl)%0A%24context.Credentials%20%3D%20New-Object%20Microsoft.SharePoint.Client.SharePointOnlineCredentials(%24UserName%2C%24Securepass)%0A%24Web%20%3D%20%24context.Web%0A%24AllProperties%3D%24Web.AllProperties%0A%24context.Load(%24Web)%0A%24context.Load(%24AllProperties)%0A%24context.ExecuteQuery()%0A%24Web.MembersCanShare%3D%24false%0A%24web.Update()%3B%0A%24web.Context.ExecuteQuery()%0A%24AssociatedMember%3D%24web.AssociatedMemberGroup%0A%24context.Load(%24AssociatedMember)%0A%24context.ExecuteQuery()%0A%24web.AssociatedMemberGroup.AllowMembersEditMembership%20%3D%20%24false%0A%24web.AssociatedMemberGroup.Update()%3B%0A%24web.Context.ExecuteQuery()%20%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-18936%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20the%20%22Allow%20members%20to%20share%22%20SharePoint%20site%20Access%20Requests%20setting%20using%20Of%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-18936%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Harold%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAre%20you%20using%20SPO%3F%26nbsp%3BThis%20url%20might%20point%20you%20in%20the%20right%20direction%20regarding%20changing%20the%20setting%20programatically%20for%20SharePoint%20online%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fchandru%2F2015%2F12%2F31%2Fsharepoint-onlinecsom-change-access-requests-settings%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fblogs.msdn.microsoft.com%2Fchandru%2F2015%2F12%2F31%2Fsharepoint-onlinecsom-change-access-requests-settings%2F%3C%2FA%3E%20(there%20is%20a%20comment%20with%20a%20suggestion%20to%20how%20this%20can%20be%20removed%20with%20powershell)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20just%20started%20looking%20into%20this%2C%20so%20haven't%20tested%20this%20myself%20yet.%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ELet%20me%20know%20when%20you%20find%20a%20way%20to%20have%20this%20setting%20un-checked%20during%20site%20provisioning%20with%20PnP%20Provisioning%20Engine%2C%26nbsp%3Bas%20I%20am%20currently%20searching%20for%20that%20myself.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Frequent Contributor

How can I set the "Allow members to share the site and individual files and folders" setting using the Office Dev PnP Provisioning Engine or PowerShell commands? I haven't found this specific setting in the commands.

 

I mean changing the following setting(s) by PowerShell / remote provisioning:

Access Requests Allow members to share.png

12 Replies
Highlighted

Hello Harold, 

 

Are you using SPO? This url might point you in the right direction regarding changing the setting programatically for SharePoint online: 

https://blogs.msdn.microsoft.com/chandru/2015/12/31/sharepoint-onlinecsom-change-access-requests-set... (there is a comment with a suggestion to how this can be removed with powershell)

 

I have just started looking into this, so haven't tested this myself yet. 


Let me know when you find a way to have this setting un-checked during site provisioning with PnP Provisioning Engine, as I am currently searching for that myself.

 

Highlighted

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

 

$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() 
Highlighted

I created a extention for that:

  try
                {
                    Web rootweb = ctx.Site.RootWeb;
                    ctx.Load(rootweb, w => w.MembersCanShare);
                    ctx.ExecuteQueryRetry();
                    SharingConfiguration sharingSettings = configurationData.ToConfigObject<SharingConfiguration>();
                    // Set MembersCanShare, default to false

                    rootweb.MembersCanShare = sharingSettings.Sharing.MembersCanShare ? sharingSettings.Sharing.MembersCanShare : false;
                    rootweb.Update();
                    ctx.Load(rootweb, w => w.AssociatedMemberGroup.AllowMembersEditMembership);
                    ctx.ExecuteQueryRetry();

                    // Set AllowMembersEditMembership, default to false
                    rootweb.AssociatedMemberGroup.AllowMembersEditMembership = sharingSettings.Sharing.AllowMembersEditMembership ? sharingSettings.Sharing.AllowMembersEditMembership : false;
                    rootweb.AssociatedMemberGroup.Update();
                    ctx.ExecuteQueryRetry();

                    ctx.Load(rootweb, w => w.RequestAccessEmail);
                    ctx.ExecuteQueryRetry();

                    rootweb.RequestAccessEmail = sharingSettings.Sharing.RequestAccessEmail;
                    rootweb.Update();
                    ctx.ExecuteQueryRetry();
                }
                catch (Exception ex)
                {
                    TraceHelper.WriteErrorToListener("LogFile", ex.Message);
                }
Highlighted

Great replies of you all. Thanks! I'm sure I'll be able to generate a solution using your input next week. I'll update when I got it working.

Highlighted

Is this for SharePoint On-Line or SharePoint On-Premises ? Or Both ?

Highlighted

Hi Nigel,

 

my example could be used for both..

 

Kr,

 

Paul

Highlighted

Hi,

So there is no support for this in PNP-Powershell or the provisioning engine right now?

Russell

Highlighted

Heres the equivalent powershell. This works in O365

function DisableMemberSharing($siteUrl ) {

Connect -Url $siteUrl

$web = Get-PnPWeb -Includes MembersCanShare, AssociatedMemberGroup.AllowMembersEditMembership

$web.MembersCanShare=$false

$web.AssociatedMemberGroup.AllowMembersEditMembership=$false

$web.AssociatedMemberGroup.Update()

$web.Update()

$web.Context.ExecuteQuery()

 

}

 

 

Highlighted

Hi,

Is there also a command to enable/disable the "Allow access requests" via powsershell?

Cheers

Highlighted

For SharePoint online you can try this:

 

Connect-PnPOnline -url https://contoso.sharepoint.com/sites/test

Set-PnPRequestAccessEmails -Emails " "

Highlighted

@Mani Mehrabi Thanks! I have tried the suggested but it does not work. In the Access Request Settings it seems MS has also added a new radio button for choosing either email or the Site owners.

Highlighted

I ran into this same problem. Try this:

 

$web = Get-PnPWeb -Includes MembersCanShare, AssociatedMemberGroup.AllowMembersEditMembership

$web.MembersCanShare=$false

$web.AssociatedMemberGroup.AllowMembersEditMembership=$false

$web.AssociatedMemberGroup.Update()

$web.RequestAccessEmail = $null

$web.Update()

$web.Context.ExecuteQuery()