SharePoint Online: How to Disable Sharing for Non-Owners using PowerShell?

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 “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.

sharepoint online disable sharing for non-owners (members)

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

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?

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

3 thoughts on “SharePoint Online: How to Disable Sharing for Non-Owners using PowerShell?

  • Looking for a way to set the site sharing permissions to Site Owners and Members, and people with edit but only site owners can share the site. Thank you

    Reply
  • Is there any cmdlet to set this option to “Members can share files and folders, but NOT the whole site” ?

    Reply
  • How to reverse this? I also want to be able to set the setting to “Sharing documents en folders, but not the site”.

    Reply

Leave a Reply