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 six time Microsoft MVP (Since 2015) with over 16 years of extensive experience with major expertise on SharePoint, SharePoint based development, Microsoft 365, Microsoft Teams, .Net Platform and Microsoft BI. He is currently working Sr Microsoft Consultant at Olive + Goose. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past 12 years and worked on different intranet/intranet solutions for private & govt. sector majorly in United states and Gulf region and have experience of working with multiple Fortune 500 companies. He is a trainer, technology evangelist and also speaks in community forums.

Leave a Reply