Configure sharing on your SharePoint Site

SharePoint sites have by default the possibility to be shared by any member belonging to the site and with it, they can share with anyone of your organization or external. With this, you can end with the site being shared with a lot of users without you realizing that happened.

Today, we will explain how to disable/enable the sharing of a site on your SharePoint Online using the PowerShell. Note that you need to be Admin of the site collection to be able to change this setting.  After this setting is changed, the owners of the site will receive an email to allow or not the new user.

Connect-PnPOnline -Url

$ReadHost = Read-Host "Do you want to disable the share for the members of the Site? (y|n)"
if($ReadHost -match 'y'){
 $value = $false
 $value = $true

$Web = Get-PnPWeb
$context = Get-PnPContext
$AllProperties = $Web.AllProperties
$Web.MembersCanShare = $false
$AssociatedMember = $Web.AssociatedMemberGroup
$Web.AssociatedMemberGroup.AllowMembersEditMembership = $false
Write-Host "Done" -BackgroundColor Green -ForegroundColor Black


After you run this script the member of the site will no longer be able to share the site. I believe this option to share or not, it’ll always depend on the purposes of the site. I strongly recommend reading the blogs below which have more information about doing this on SharePoint interfaces and also their thoughts about this.


Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *