- Open Visual Studio 2010.
- Go to File => New => Project.
- Select Console Application template from
the installed templates.
- Enter the Name and Click on Ok.
- Add the following Reference.
Microsoft.SharePoint.dll
- Add the following Namespace.
Using Microsoft.SharePoint;
- Replace Program.cs with the following
code.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
Microsoft.SharePoint;
using
System.Text;
namespace
EnableSharePointWorkspace
{
class
Program
{
static void
Main(string[] args)
{
using (SPSite
site = new
SPSite("https://servername:1111/sites/ContentTypeHub/"))
{
using (SPWeb
web = site.OpenWeb())
{
SPList list =
web.Lists.TryGetList("Shared Documents");
if (list !=
null)
{
//Enable Sync to SharePoint Workspace
list.ExcludeFromOfflineClient =
false;
//To Disable Sync to SharePoint Workspace =>
list.ExcludeFromOfflineClient = true;
list.Update();
Console.WriteLine("Sync to
SharePoint Workspace is Enabled");
}
else
{
Console.WriteLine(list.Title + "
does not exists in the site");
}
Console.ReadLine();
}
}
}
}
}
- Build the solution.
- Hit F5.
Enable Sync to SharePoint Workspace using
Powershell:
- Go to Start => All Programs =>Microsoft
SharePoint 2010 Products.
- Right click on SharePoint 2010 Management
Shell and then click on Run as Administrator.
- Run the following script.
$site = Get-SPSite "https://serverName:1111/sites/ContentTypeHub"
$web = $site.OpenWeb()
$list = $web.Lists.TryGetList("Shared Documents")
if ($list -ne $null)
{
# Enable Sync to SharePoint Workspace
$list.ExcludeFromOfflineClient = $false
# To Disable Sync to SharePoint Workspace => $list.ExcludeFromOfflineClient
= $true
$list.Update()
write-host " Sync to SharePoint Workspace is enabled"
}
else
{
write-host $list.Title "does not exists in the site"
}
Join the conversation! Your thoughts help the community grow.