question

Dhamley avatar image
0 Votes"
Dhamley asked JinweiLi-MSFT edited

Need to hide the sync button for all SharePoint Online Site Collections

Hi Team


I am looking for a script where it could hide the sync button for all SharePoint Online Site Collections in office 365
Could any please help me ....

Thanks in advance !

office-sharepoint-onlinesharepoint-devoffice-sharepoint-server-developmentoffice-sharepoint-server-customization
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JinweiLi-MSFT avatar image
1 Vote"
JinweiLi-MSFT answered JinweiLi-MSFT edited

Hi @Dhamley,

There is no direct tenant settings to remove Sync icon from all sites or newly created site. You could use CSOM PowerShell to solve it.

PowerShell commands:

 #Load SharePoint CSOM Assemblies
 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"
    
 Function Disable-SPOSyncButton([String]$SiteURL)
 { 
     Try{
         #Setup the context
         $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
         $Ctx.Credentials = $Credentials
     
         #Get the Web and Sub Sites
         $Web = $Ctx.Web
         $Ctx.Load($Web)
         $Ctx.Load($Web.Webs)
         $Ctx.ExecuteQuery()
     
         $Web.ExcludeFromOfflineClient=$true
         $Web.Update()
         $Ctx.ExecuteQuery()
         Write-Host -f Green "Sync Button is Disabled for the Site:" $($SiteURL)
     
         #Iterate through each subsite of the current web
         ForEach ($Subweb in $Ctx.Web.Webs)
         {
             #Call the function recursively
             Disable-SPOSyncButton -SiteURL $Subweb.url
         }
     }
     Catch {
         write-host -f Red "Error Disabling Sync Button!" $_.Exception.Message
     }
 }
     
 #Set parameter values
 $SiteURL="https://crescent.sharepoint.com/"
     
 #Get Credentials to connect
 $Cred= Get-Credential
 $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
     
 #Call the function
 Disable-SPOSyncButton -SiteURL $SiteURL

References:

PowerShell to Remove Sync Button in All Sites of the Site Collection
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Dhamley,

Is there any update on this thread? Comment here if you still need any help.

0 Votes 0 ·