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, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose. Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies. Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.

Leave a Reply