You can see the Sync option on SharePoint document libraries by default, there are requirements to enable or disable sync option on a document library. There are multiple ways to perform this task by enabling it through the SharePoint site for all document libraries, from a document library or using PowerShell.

Today, I will be sharing details on how to enable or disable Sync option on SharePoint Online Document Library through library settings and PowerShell

Enable / Disable Sync button in a Document Library

Follow the below steps to enable / disable sync button for a document library

  • Got to Library Settings
  • Click on advance settings
  • Select “Yes” or “No” for “Offline Client Availability
  • Save the settings

Now the sync option on the document library would be enable (if you selected Yes) or disabled (if you selected No).

Enable / Disable Sync button in a Document Library using PowerShell

I have written a simple PowerShell function to enable/disable sync for a document library using a simple call, below is the PowerShell script which allows you to perform this action, script only need three parameters site url, document library name and required action.

#Author: Adnan Amin
#blog: Https://mstechtalk.com
# Enable / disable sync option for a SharePoint Document Library 
# Author: Adnan Am


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"

#Fuction to enable or disable sync in a document library
function EnableDisableSync ($siteURL, $libraryName, $action)
{ 
     try 
    {  
        $cred= Get-Credential

        $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL) 
        $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($cred.Username, $cred.Password)
        $ctx.Credentials = $credentials 
   
        $list = $ctx.Web.Lists.GetByTitle($libraryName) 
        $ctx.Load($list) 
        $ctx.ExecuteQuery() 
 
        #Operation Type 
        if ($action -eq "Enable")  
        {  
        Write-Host "Enabling sync on document library"
            $list.ExcludeFromOfflineClient=$false 
            
        }else { 
            Write-Host "Disabling sync on document library"
            $list.ExcludeFromOfflineClient=$true 
        }     
        $list.Update() 
        $ctx.ExecuteQuery() 
        $ctx.Dispose() 
    } 
    catch [System.Exception] 
    { 
        Write-Host -ForegroundColor Red $_.Exception.ToString()    
    }     
} 
 
EnableDisableSync -siteURL "https://mstalk.sharepoint.com" -libraryName "Documents" -action "Enable" 

Adnan is two time SharePoint MVP (Most Valuable Professional) with over 12 years of extensive experience with major expertise on SharePoint Server, Office 365, .Net Platform and Microsoft BI. He is currently working SharePoint Architect at FMT Consultants. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past nine years and worked on different intranet/intranet solutions for private & govt. sector majorly in Gulf region, which include OOB and customized solutions. He is a trainer, technology evangelist and also speaks in community forums.

Leave a Reply