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

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

sharepoint online disable document library sync

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

To disable the sync button for a single library,

  • Go to: Library Settings >> Advanced Settings 
  • 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:

$SiteURL = ""
$ListName = "Branding"

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

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

#Exclude List or Library from Sync
$List.ExcludeFromOfflineClient = $true

Disable sync in SharePoint Online Site:

If you want to disable sync for your entire site:

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

This hides sync button from all libraries in SharePoint Online.

Set Search and Offline Availability using PnP PowerShell

To disable sync button SharePoint Online, use this PowerShell script.

$SiteURL = ""

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

#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
Write-Host "Offline Client Availability is Disabled!" -f Green

Please note this setting is at “Site” level, not a site collection level and needs to be set on all site of the site collection, so lets 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 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)
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials

        #Get the Web and Sub Sites
        $Web = $Ctx.Web

        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

#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

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!

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

  • May 24, 2021 at 11:46 AM

    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.


Leave a Reply