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

Dhamley 31 Reputation points
2022-05-09T20:27:13.407+00:00

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 !

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,227 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,682 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,675 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,575 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jinwei Li-MSFT 4,721 Reputation points Microsoft Vendor
    2022-05-10T06:29:44.243+00:00

    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 person found this answer helpful.

  2. Adam Bilski 21 Reputation points
    2022-10-21T10:50:38.8+00:00

    Hi @Jinwei Li-MSFT ,

    I've tried using your solution but it just wont do it for all sites, it will only do it for the site url chosen:

    Call the function

    Disable-SPOSyncButton -SiteURL $SiteURL
    cmdlet Get-Credential at command pipeline position 1
    Supply values for the following parameters:
    Sync Button is Disabled for the Site: https://contoso.sharepoint.com/

    and then it stops, any idea ?

    Thanks,
    Adam

    0 comments No comments