none
Remove the Sync Ribbon from all sites

    Question

  • Hi,

    we have a few thousand sites.

    we need to remove the "sync" ribbon on all of them.

    i see many answers on how to do it in on-premise sharepoint, but couldn't figure out how to do so on sharepoint online via Powershell.

    thanks!

    Monday, January 2, 2017 7:38 AM

Answers

  • OK guys i've figured it out.

    posting my C# Code for Future Hair-Pulling-frustrated guys like me....

    public static void setExcludeFromOfflineClient(string siteurl, bool disableOffline)
                {
                    using (ClientContext site = new ClientContext(siteurl))
                    {
                        SecureString pass = new SecureString();
                        string passw = "password";
                        foreach (char c in passw.ToCharArray()) pass.AppendChar(c);
                        SharePointOnlineCredentials creds = new SharePointOnlineCredentials("admin@tenant.onmicrosoft.com", pass);
                        site.Credentials = creds;
                        Web webs = site.Web;
                        site.ExecuteQuery();
                        List collList = webs.Lists.GetByTitle("Documents");
                        CamlQuery camlQuery = new CamlQuery();
                        site.Load(collList,
                            items => items.ExcludeFromOfflineClient,
                            items => items.Title
                            );
                        site.ExecuteQuery();
                        collList.ExcludeFromOfflineClient = disableOffline;
                        collList.Update();
                        site.ExecuteQuery();
                    }
    
                }

    • Marked as answer by Benny Barak Tuesday, January 3, 2017 12:09 PM
    Tuesday, January 3, 2017 12:09 PM

All replies

  • Hi,

    Yes, SharePoint online doesn’t provide PowerShell cmdlet to set synchronization property.

    You need to check “No” in Site Settings > Search and Offline Availability > Offline Client Available field manually.

    Here are Windows PowerShell for SharePoint Online cmdlets for your reference:

    https://technet.microsoft.com/en-us/library/fp161364.aspx

    Thanks,

    Dean Wang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, January 3, 2017 6:42 AM
    Moderator
  • there's a way to do it with the sharepoint client, but i just didn't figure out how.

    when i do this:

    Add-Type -Path C:\1\sharepointclientonline\Microsoft.SharePoint.Client.dll
    Add-Type -Path C:\1\sharepointclientonline\Microsoft.SharePoint.Client.Publishing.dll
    $securePassword = ConvertTo-SecureString "password" -AsPlainText -Force
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("admin@tenant.onmicrosoft.com", $securePassword)
    $ctx = New-Object Microsoft.SharePoint.Client.ClientContext("https://tenant.sharepoint.com/sub/sub1/")
    $ctx.Credentials = $credentials
    
    $webs = $ctx.Web
    $ctx.Load($webs)
    $ctx.Load($webs.Webs)
    $ctx.ExecuteQuery()
    foreach ($list in $webs.Webs) {echo $list.Title}
    #$webs.GetList(“Shared Documents”).ExcludeFromOfflineClient
    #$webs.Lists.Update()
    $webs.ExcludeFromOfflineClient=$true
    $webs.ExcludeFromOfflineClient
    #$webs.GetList(“Shared Documents”).Update()
    $webs.Update()
    $webs | select -Property Title, ExcludeFromOfflineClient

    it say's 

    ExcludeFromOfflineClient True

    but doesn't work....

    Tuesday, January 3, 2017 6:50 AM
  • Hi,

    If you want to disable sync button, you need to set ExcludeFromOffilneClient=$false.

    Thanks,

    Dean Wang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, January 3, 2017 10:44 AM
    Moderator
  • OK guys i've figured it out.

    posting my C# Code for Future Hair-Pulling-frustrated guys like me....

    public static void setExcludeFromOfflineClient(string siteurl, bool disableOffline)
                {
                    using (ClientContext site = new ClientContext(siteurl))
                    {
                        SecureString pass = new SecureString();
                        string passw = "password";
                        foreach (char c in passw.ToCharArray()) pass.AppendChar(c);
                        SharePointOnlineCredentials creds = new SharePointOnlineCredentials("admin@tenant.onmicrosoft.com", pass);
                        site.Credentials = creds;
                        Web webs = site.Web;
                        site.ExecuteQuery();
                        List collList = webs.Lists.GetByTitle("Documents");
                        CamlQuery camlQuery = new CamlQuery();
                        site.Load(collList,
                            items => items.ExcludeFromOfflineClient,
                            items => items.Title
                            );
                        site.ExecuteQuery();
                        collList.ExcludeFromOfflineClient = disableOffline;
                        collList.Update();
                        site.ExecuteQuery();
                    }
    
                }

    • Marked as answer by Benny Barak Tuesday, January 3, 2017 12:09 PM
    Tuesday, January 3, 2017 12:09 PM