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 Amin is a Microsoft MVP for Microsoft 365 (since 2015) and a Senior Microsoft Consultant. He writes practical guides and PowerShell scripts for SharePoint, OneDrive, Teams and Copilot admins.

Leave a Reply

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