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, 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