SharePoint Online: How to Disable "Sync" Button in 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 Document Library?
To disable 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 Sync button from the library.

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 "Search" group
  • Set "No" for "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
$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
Lets 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

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.