SharePoint Online: How to Disable the “Sync” Button in a Document Library?

Requirement: Disable the Sync button in SharePoint Online or OneDrive for Business Document Library.

sharepoint online disable document library sync

How to disable the sync button in a SharePoint Online Document Library?

Are you looking for a way to disable sync in SharePoint Online? Maybe you’re experiencing performance issues or synchronization errors, and you want to try disabling sync to see if that helps. This article will show you how to disable sync in SharePoint Online.

To disable the sync button for a single library, follow these steps:

  1. Go to: Library Settings >> Advanced Settings 
  2. Set “No” for “Offline Client Availability”
    sharepoint online disable document library sync

This disables the Sync button from the library.

PnP PowerShell to Disable Sync in a SharePoint Online Library:

When you do not want users to be able to sync documents from a document library, use this PowerShell!

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"
$ListName = "Branding"

#Connect to PnP
Connect-PnPOnline -url $SiteURL -Interactive

#Get the Library
$List = Get-PnPList $ListName

#Exclude List or Library from Sync
$List.ExcludeFromOfflineClient = $true
$List.Update()
Invoke-PnPQuery

Disable sync in SharePoint Online Site

Disabling the sync feature is a good idea if you don’t need your users to have offline copies on their devices, or if you’re worried about accidentally deleting or modifying files. To disable sync in SharePoint Online sites, just follow these steps:

If you want to disable sync for your entire site,

  1. Go to Site Settings >> Click on “Search and Offline Availability” under the “Search” group.
  2. Set “No” for the “Offline Client Availability” setting.
    sharepoint online hide sync button

This hides the sync button from all libraries in SharePoint Online.

Set Search and Offline Availability using PnP PowerShell

Occasionally, you may want to disable sync for an entire site. This can be done quickly by following these steps. To disable the sync button in SharePoint Online, use this PowerShell script.

#Parameters
$SiteURL = "https://Crescent.sharepoint.com/sites/Marketing"

#Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -Interactive

#Get the Web
$Web = Get-PnPWeb -Includes ExcludeFromOfflineClient

#Set "Allow items from this site to be downloaded to offline clients?" to "No"
$web.ExcludeFromOfflineClient = $True
$web.Update()
Invoke-PnPQuery
Write-Host "Offline Client Availability is Disabled!" -f Green

Please note this setting is at the “Site” level, not a site collection level, and needs to be set on all sites of the site collection, so let’s use PowerShell to disable sync on all sites in a SharePoint Online site collection!

PowerShell to Remove Sync Button in All Sites of the Site Collection

Let’s hide the sync button for a SharePoint Online Site Collection.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

Function Disable-SPOSyncButton([String]$SiteURL)
{  
    Try{
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials

        #Get the Web and Sub Sites
        $Web = $Ctx.Web
        $Ctx.Load($Web)
        $Ctx.Load($Web.Webs)
        $Ctx.ExecuteQuery()

        $Web.ExcludeFromOfflineClient=$true
        $Web.Update()
        $Ctx.ExecuteQuery()
        Write-Host -f Green "Sync Button is Disabled for the Site:" $($SiteURL)

        #Iterate through each subsite of the current web
        ForEach ($Subweb in $Ctx.Web.Webs)
        {
            #Call the function recursively 
            Disable-SPOSyncButton -SiteURL $Subweb.url
        }
    }
    Catch {
        write-host -f Red "Error Disabling Sync Button!" $_.Exception.Message
    }
}

#Set parameter values
$SiteURL="https://crescent.sharepoint.com/"

#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Call the function 
Disable-SPOSyncButton -SiteURL $SiteURL

To disable sync in OneDrive for Business sites, use: How to Hide Sync in OneDrive for Business at the Tenant Level?

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

8 thoughts on “SharePoint Online: How to Disable the “Sync” Button in a Document Library?

  • Hi, great piece, however when trying to get it disabled for site collection it still only does one site and stops ?

    Any idea ?

    Reply
  • Anyone found a solution to ‘Add Shortcut to One Drive’ but stop the downloading/syncing of files to the local client? Its handy to access the SharePoint libraries through One Drive, but we don’t want data gong down to the local client device. Stopping ‘sync’ (using any method) breaks the Shortcut in One Drive 🙁

    Reply
    • My OneDrive Shortcuts are still working, after disabling the sync option.

      Reply
  • can we disable the sync for a specific user

    Reply
  • Hi. I can’t really tell if the scripts are the equivalent of what you show in the gui (disabling offline client availability) or simply hiding the button more cosmetically. We’re looking for the latter, as we want to use the “Add shortcut to Onedrive” button instead of the Sync button and therefore want to get the Sync button out of the way. Add Shortcut uses sync, however, so disabling offline client availability would break it. I would test it myself but am so far hitting 401 and 403 errors. Thanks.

    Reply
    • We want to do this as well, “Sync” is very dangerous and needs to be disabled, but we want to retain the much less risky “Add shortcut to OneDrive”.

      The approaches described above will remove both features (I haven’t found the correct approach yet)..

      Reply

Leave a Reply

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