Advanced Settings for list in SharePoint 2010 using PowerShell


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

Go to List =>List Settings => General Settings =>Advanced Settings.

Share1.gif

Using C#:

using (SPSite site = new SPSite("http://serverName:1111/"))
{
using (SPWeb web = site.RootWeb)
{
SPListlist=web.Lists["cl"];

// Change the advanced settings

// Update the changes

list.Update();
}
}

Using PowerShell

$site=Get-SPSite "http://serverName:1111/"
$web=$site.RootWeb
$list =$web.Lists["cl"]
# Change the advanced settings
$list.Update()

Item-level Permissions:

Share2.gif


C#:

Read access

Read all items = 1
Read items that were created by the user = 2
list.ReadSecurity = 2;

Create and Edit access

Create and edit all items = 1
Create items and edit items that were created by the user = 2
None = 4

list.WriteSecurity = 4;


PowerShell:

$list.ReadSecurity = 2
$list.WriteSecurity = 4



Attachments:

Share3.gif

C#:

list.EnableAttachments = false;

PowerShell:

$list.EnableAttachments = $false