Forum Discussion
Oct 05, 2016
Changing the "Allow members to share" SharePoint site Access Requests setting using Office Dev PnP
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...
Anonymous
Oct 06, 2016I 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);
}Nigel Price
Oct 06, 2016Iron Contributor
Is this for SharePoint On-Line or SharePoint On-Premises ? Or Both ?
- AnonymousOct 07, 2016
Hi Nigel,
my example could be used for both..
Kr,
Paul
- Russell GoveNov 16, 2017Iron Contributor
Hi,
So there is no support for this in PNP-Powershell or the provisioning engine right now?
Russell
- Russell GoveNov 16, 2017Iron Contributor
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()
}