Requirement: Disable Sharing for Non-Owners in SharePoint Online.
How to Disable Sharing for Members in SharePoint?
If you are a SharePoint Online administrator, You may want to disable sharing for people who are not site owners. Perhaps you have users who need access to specific content but don’t need the ability to share it with others. This article will show you how to disable sharing for non-owners in SharePoint Online (and the other way around: allow members to share the site and individual files and folders in SharePoint Online). We will also cover using PowerShell to prevent site members from sharing the site.
To disable sharing for members in SharePoint Online, follow these steps:
- Click on Settings >> Site Settings >> Site Permissions
- Click on the “Access Request Settings” button in the ribbon.
- Uncheck “Allow members to share the site and individual files and folders.”. You can also uncheck “Allow members to invite others to the site members group, <Group Name>. This setting must be enabled to let members share the site. “
This disables the share button for non-owners (members) for a given site. If you want to allow members to share the site and individual files and folders, just enable this checkbox.
In group connected modern sites, these settings are under Settings >> Site Permissions >> Change how members can share
PowerShell to Disable Sharing for Non-Owners
Here is the PowerShell to disable sharing for non-owners in SharePoint Online:
#Config Variables $AdminSiteURL= "https://crescent-admin.sharepoint.com" $SiteURL= "https://crescent.sharepoint.com/sites/marketing" #Connect to SharePoint Online services Connect-SPOService -url $AdminSiteURL -Credential (Get-Credential) #Disable Sharing for Non-Owners Set-SPOSite -Identity $SiteURL -DisableSharingForNonOwners
To allow members to share a SharePoint Online site using PnP PowerShell, you can use the following script:
#Parameters $SiteURL = "https://crescent.sharepoint.com/sites/marketing" #Connect to PnP Online Connect-PnPOnline -Url $SiteURL -Interactive #Disable Sharing permissions settings - Disable Sharing for Non Owners Set-PnPSite -Identity $SiteURL -DisableSharingForNonOwners
Found a problem, though! When you run this script for the first time, it disables access requests! Furthermore, I don’t find any PowerShell ways to reverse this as of today (Allow members to share!) To disable the share button in SharePoint Online, use: How to Disable Share Feature in SharePoint Online?