
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)
{
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
$web= $ctx.Web
$ctx.Load($web)
#$ctx.Load($web.Webs) ##uncomment this if you need to run for all subsites under this site
$ctx.ExecuteQuery()
$web.ExcludeFromOfflineClient=$action
$web.Update()
$ctx.ExecuteQuery()
#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 "https://mstalk.sharepoint.com" -action "True"
No Comments