SharePoint Online: Enable / Disable Sync for all Sites

Sync options enables a site content to be available offline, users can sync documents using from a SharePoint Document Library using OneDrive sync client on their local drives to use them offline and can also add content and changes to it which will be uploaded when connected online.

There are requirements for some specific content where site administrators require to disable document syncing on some of the document libraries (check this this blog post to learn about enabling and disabling sync on a document library). And there could also be requirements where site administrator require to disable offline availability of all content from a site.

I will be sharing two different ways for achieving this job by enabling/disabling from site settings and PowerShell. PowerShell option would be very helpful if you trying to disable sync on multiple sites or for all sub sites under a site or site collection.

Enable / Disable Sync for a Site

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

  • Got to site settings
  • Click on “Search and Offline availability option” listed under “Search
  • Select “Yes” or “No” option for “Offline Client Availability” (check screenshot at top)
  • Save changes

This will disable the sync option from all document libraries in the site, you verify that be visiting any of the document library under that site.

Enable / Disable Sync for a Site using PowerShell

I am sharing a PowerShell script which could be helpful enabling or disabling sync at the site level. The EnableDisableSiteSync function takes two parameters site url and action, if you need to run disable or enable all sub sites under the given URL then you can iterate through all sub sites and perform the required action.

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 EnableDisableSiteSync ($siteURL, $action)
        $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 
        $web= $ctx.Web
        #$ctx.Load($web.Webs) ##uncomment this if you need to run for all subsites under this site
        #if you want run the script for all subsites under this site then follow run below cmdlets

        #foreach ($subsite in $web.Webs)
        #    $ctx.load($subsite)
        #    $ctx.ExecuteQuery()
        #    $subsite.ExcludeFromOfflineClient=$action
        #    $subsite.Update()
        #    $ctx.ExecuteQuery()

    catch [System.Exception] 
        Write-Host -ForegroundColor Red $_.Exception.ToString()    

EnableDisableSiteSync -siteURL "" -action "True"

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