Forum Discussion

sbonn's avatar
sbonn
Copper Contributor
Jun 04, 2024

sharepoint online DisableCompanyWideSharingLinks

reposting Igor's question here as per MSFT's suggestion : 

"How can I disable the 'Share with entire organization' option globally for OneDrive and SharePoint in Microsoft 365? I've examined the documentation at https://learn.microsoft.com/en-us/microsoft-365/solutions/microsoft-365-limit-sharing?view=o365-worldwide#sharing-with-specific-people and discovered PowerShell commands such as 'Set-SPOSite -Identity https://contoso.sharepoint.com -DisableCompanyWideSharingLinks Disabled' for SharePoint sites and 'Set-SPOSite -Identity https://contoso-my.sharepoint.com/personal/my_alias_contoso_com -DisableCompanyWideSharingLinks Disabled' for OneDrives. The challenge is executing these commands for each site and user in our environment. Is there a method to apply this globally across the entire organization?


  • Jeremy-MAG's avatar
    Jeremy-MAG
    Copper Contributor

    sbonn just having the same issue - ended up doing this;

    - list all sharepoint sites / URLs in a csv

    - short PS script to loop through them and set the option

     

    works fine but .. will need to do it on all future sites.. would love a global option to set this as default..

  • f61361217's avatar
    f61361217
    Copper Contributor

    In SharePoint Online, the DisableCompanyWideSharingLinks setting restricts the creation of anonymous sharing links across the entire organization. This prevents users from generating links that allow anyone with access to the link to view or edit content without signing in. It enhances security by enforcing authentication for shared content, ensuring only authorized users can access shared files or folders. Administrators can configure this policy to align with company security standards and prevent accidental over-sharing.
  • sbonn 

     

    Take this:

     

    1. Install the SharePoint Online Management Shell 

    2. Connect to SharePoint Online using the following command:

      Connect-SPOService -Url https://<your-tenant>-admin.sharepoint.com
      
    3. Set the organization-wide sharing settings. To disable sharing with the entire organization, you can use the following command:

      Set-SPOTenant -SharingCapability Disabled
      
    4. Apply the setting to all existing sites. You can loop through all sites and apply the setting:

      $sites = Get-SPOSite -Limit All
      foreach ($site in $sites) {
          Set-SPOSite -Identity $site.Url -DisableCompanyWideSharingLinks Disabled
      }

Resources