Advanced Settings for Document library in SharePoint 2010 using PowerShell

In this article we will be seeing how to change the Advanced Settings for Document library in SharePoint 2010 using PowerShell and c#.

Go to Document Library => Library Settings => General Settings =>Advanced Settings.



















Using C#:

  1. using (SPSite site = new SPSite("http://serverName:1111/"))           

  2. {

  3. using (SPWeb web = site.RootWeb)               

  4. {

  5. SPList docLibrary=web.Lists["Doc Library"];

  6. // Change the advanced settings

  7. // Update the changes                   

  8. docLibrary.Update();               

  9. }           

  10. }

Using PowerShell

  1. $site=Get-SPSite "http://serverName:1111/"

  2. $web=$site.RootWeb

  3. $docLibrary =$web.Lists["Doc Library"]

  4. # Change the advanced settings

  5. $docLibrary.Update()

Content Types:






C#:

  1. docLibrary.ContentTypesEnabled = false;

PowerShell:

  1. $docLibrary.ContentTypesEnabled = $false

Opening Documents in the Browser:






C#:

  1. // Open in the client application docLibrary.DefaultItemOpen = DefaultItemOpen.PreferClient;

  2. // Open in the browser docLibrary.DefaultItemOpen = DefaultItemOpen.Browser;

  3. // Use the server default docLibrary.DefaultItemOpenUseListSetting = false;

PowerShell:

  1. #Open in the client application $docLibrary.DefaultItemOpen = "PreferClient"

  2. #Open in the browser $docLibrary.DefaultItemOpen = "Browser"

  3. #Use the server default $docLibrary.DefaultItemOpenUseListSetting = $false

Custom Send To Destination:







C#:

  1. docLibrary.SendToLocationName = "Shared Documents"; docLibrary.SendToLocationUrl = "http://serverName:1111/Shared%20Documents/";

PowerShell:

  1. $docLibrary.SendToLocationName = "Shared Documents";

  2. $docLibrary.SendToLocationUrl = "http://serverName:1111/Shared%20Documents/";

Folders:





C#:

  1. docLibrary.EnableFolderCreation = false;

PowerShell:

  1. $docLibrary.EnableFolderCreation = $false

Search:





C#:

  1. docLibrary.NoCrawl = true;

PowerShell:

  1. $docLibrary.NoCrawl = $true

Offline Client Availability:





C#:

  1. docLibrary.ExcludeFromOfflineClient = true;

PowerShell:

  1. $docLibrary.ExcludeFromOfflineClient = $true

Site Assets Library:




C#:

  1. docLibrary.IsSiteAssetsLibrary = false;

PowerShell:

  1. $docLibrary.IsSiteAssetsLibrary = $false

Datasheet:





C#:

  1. docLibrary.DisableGridEditing = true;

PowerShell:

  1. $docLibrary.DisableGridEditing = $true

Dialogs:






C#:

  1. docLibrary.NavigateForFormsPages = true;

PowerShell:

  1. $docLibrary.NavigateForFormsPages = $true