Keep always data in SPO and ODfB: Remove Sync options for Sharepoint and OneDrive

Sergio Londono 321 Reputation points
2023-10-14T14:57:56.07+00:00

Hello team,

We need to block sync SharePoint and Onedrive in user devices.

I disabled in SPO admin center the option to "show the Sync button on the OneDrive website", however it icon still appears.

I think the workaround for this requirement is to enable "Allow syncing only from computers joined to specific domains" and put as domain controller GUID any fictional value, this will block the sync for OneDrive, but, It will also block sync for SPO?

what do you think about this workaround?

User's image

User's image

User's image

OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
810 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,630 questions
OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,122 questions
{count} votes

Accepted answer
  1. Ling Zhou_MSFT 13,110 Reputation points Microsoft Vendor
    2023-10-17T05:21:29.23+00:00

    Hi @Sergio Londono,

    I apologize that I didn't make the third part clearer. I will restate that part here. Please forgive me for modifying your comment to remove my tenant's name, as I accidentally gave out my tenant's name.

    The purpose of this PowerShell is to hide all sync buttons on a site collection and its subsites. So $SiteURL is the URL of a site collection. You can modify this URL to achieve sync button hiding for other site collections.

    1.Download SharePoint Online Management Shell and install it.

    2.Modify the PowerShell commands I provided. Just modify $SiteURL, $Username, and $Password. The username and password are the ones you use to log in to Share Point Online. Please make sure that the account you are using is the admin of this site collection.

    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://Your Site Collection URL"
    
    #Replace Username and Password
    $Username = 'YourUserName@tenant.onmicrosoft.com'
    $Password = 'YourPassword'
    $pass = ConvertTo-SecureString -AsPlainText $Password -Force
    
    $SecureString = $pass
    # Users you password securly
    $MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username,$SecureString
    
    #Get Credentials to connect
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($MySecureCreds.Username, $MySecureCreds.Password)
     
    #Call the function
    Disable-SPOSyncButton -SiteURL $SiteURL
    

    3.Open SharePoint Online Management Shell.

    User's image

    4.Copy the commands and press Enter to execute it. After success, you can see the green prompt message.

    image

    5.Clear your browser cache and then revisit the site collection and you will see that the sync button is hidden on the site collection and all its subsites.


    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Ling Zhou_MSFT 13,110 Reputation points Microsoft Vendor
    2023-10-16T05:11:57.09+00:00

    Hi @Sergio Londono,

    Thank you for posting in this community.

    The method described in your question is about disabling the Sync button in OneDrive for Business.

    If you want to disable the Sync button on SharePoint Online, please refer to the following:

    Please note that SharePoint does not have a way to directly hide the Sync button on an entire tenant, only for a document library, a site and all sites on a site collection.

    1.Disable sync at the library level (Make sure you have the full permission level for this file library):

    • Navigate to the library where you want to disable sync, then click Gear Icon > Library Settings.
    • Click on Advanced Settings.
    • Scroll down to the middle of the page, and under Offline Client Availability, select No (default is Yes). User's image
    • Click OK at the bottom.
    • You will now notice that the library lacks a Sync Button. User's image

    2.Disable sync at the Site level (Make sure you are the admin for this site):

    • Navigate to the site where you want to disable synchronization. Click Gear Icon > Site Information > View all site settings.
    • Click on Search and offline availability under Search.
    • Under Offline Client Availability select No (default is Yes). User's image
    • Click OK at the bottom of the page.
    • Just like with Library changes above, you will see the Sync button disappear from the library (or all libraries located on this site).

    3.Remove Sync Button in All Sites of the Site Collection:

    Please use SharePoint Online Management Shell to run following PowerShell:

    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://Yourtenant.sharepoint.com/sites/karley10"
    
    #Replace Username and Password
    $Username = 'UserName@tenant.onmicrosoft.com'
    $Password = 'Password'
    $pass = ConvertTo-SecureString -AsPlainText $Password -Force
    
    $SecureString = $pass
    # Users you password securly
    $MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username,$SecureString
    
    #Get Credentials to connect
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($MySecureCreds.Username, $MySecureCreds.Password)
     
    #Call the function
    Disable-SPOSyncButton -SiteURL $SiteURL
    

    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.