Thursday, 21 October 2010

Change SharePoint list settings using PowerShell - Part 2: Advanced Settings

This article follows on from Part 1 last week, where I detailed how to change the General and Versioning Settings of a SharePoint list or document library with PowerShell.

This part covers changing the Advanced Settings of a list. As a recap, you can use the following script to change the settings of a specifically named list on each site in the site collection. In the example below, we are changing the settings of a document library called “Shared Documents” on each site in the “http://portal” site collection:

#Change these variables to your site URL and list name
$site = Get-SPSite http://portal
$listName = "Shared Documents"

#Walk through each site in the site collection
$site | Get-SPWeb | ForEach-Object {

#Get the list in this site
$list = $_.Lists[$listName]

#Make the list changes

#Update the list

#Dispose of the site object

The table below shows the Advanced Settings we can change, with snapshots of the same settings from the list admin UI. To use any of these settings from the table, copy them into the script above, underneath the “#Make the list changes” line:

Document Template
(document libraries only)
The following set of commands will upload a new document template from a path on your computer or network (UNC) path and change the document template setting on the list:

#Upload new document template file from computer
$newTemplateFile = Get-ChildItem "C:\LocalPath\Test Document.dotx"
$templateFolderPath = $_.Url + "/" + $list.RootFolder.Url + "/Forms"
$templateFolder = $_.GetFolder($templateFolderPath)
$uploadPath = $templateFolder.Url + "/" + $newTemplateFile.Name
$spNewTemplateFile = $templateFolder.Files.Add($uploadPath, $newTemplateFile.OpenRead(), $true)

#Change list setting to the template file uploaded
$list.DocumentTemplateUrl = $uploadPath

Note: If you are running this script on a single site rather than in bulk on each site in the site collection, change the $_ references above to the variable you have assigned to the site – e.g., $web

Opening Documents in the Browser
(document libraries only)
There are a couple of settings affecting these options. Use the following commands to set one of the first two options:

#Open in the client application
$list.DefaultItemOpen = "PreferClient”

#Open in the browser
$list.DefaultItemOpen = "Browser"

If you want to set the “Use the server default” option, use the following command:

$list.DefaultItemOpenUseListSetting = $false
Custom Send To Destination
(document libraries only)
For this option you have to set a destination name and URL of the custom Send To location:

$list.SendToLocationName = "Home Site"
$list.SendToLocationUrl = "http://Portal/Shared Documents"

Item-level Permissions
(lists only)
There are two options on this section, depending on whether you are looking to restrict user read or write access.

Read access
This setting uses a numerical value to determine which option is set:

Read all items = 1
Read items that were created by the user = 2

For example, the following command would be used to configure this setting to “Read items that were created by the user”, as pictured above:

$list.ReadSecurity = 2

Create and Edit access
This setting also uses a numerical value to set the option desired:
Create and edit all items = 1
Create items and edit items that were created by the user = 2
None = 4

For example, the following command would be used to configure this setting to “None”, as pictured above:

$list.WriteSecurity = 4
E-Mail Notification
(task and issue based lists only)
This command will enable the “Send e-mail when ownership is assigned” option:

$list.EnableAssignToEmail = $true
(lists only)
The following command will disable attachments on the list:

$list.EnableAttachments = $false
Folders image
Use the following line to disable the “New Folder” command on list and library menus:

$list.EnableFolderCreation = $false
Search image
Careful with the wording on this one, as setting it to $true will set it to No in the UI, as pictured above:

$list.NoCrawl = $true
Offline Client Availability image
Similar to the way the Search option works above, setting this one to $true will set it to No in the UI, as pictured above:

$list.ExcludeFromOfflineClient = $true
Site Assets Library
(document libraries only)
This setting will switch the document library to be a site assets library:

$list.IsSiteAssetsLibrary = $true
Datasheet image
Careful with the wording on this one also, as setting it to $false will set it to Yes in the UI, as pictured above:

$list.DisableGridEditing = $false
Dialogs image
Similar to the way the Datasheet option works above, setting this one to $true will set it to No in the UI, as pictured above:

$list.NavigateForFormsPages = $true

In Part 3 of this series, I’ll cover a few extra settings you can configure on a list with PowerShell, including some options hidden from the UI…


  1. Do you have part3 already available?

  2. Not yet - having a few weeks off so probably 2011 now I'm afraid

  3. Phil
    Nice Post, Is there a way to loop it and change the default open behavior for all document libraries not just for document libraries called "Shared Document"? I tried to do


    but I cannot set a defaultitemopen this way. Any help is appreciated.

  4. Hi Avinash,

    You could enumerate through all lists and run a check on their type using the following IF statement:

    if ($list.BaseType -eq "DocumentLibrary")

  5. Hi again Avinash,

    Just remembered that I do a similar operation to the one you requested on the second script listed in this article:

    For example:

    #Go through each document library in the site
    $_.Lists | where { $_.BaseTemplate -eq "DocumentLibrary" } | ForEach-Object {

    write-host "Checking list:"$_.Title

    #Do whatever you need to do here


  6. Great site; When discussing PowerShell i often reference you site!

    Quick question regarding this solution: Is there an easy way to tell Word & Powerpoint to open in client applications while having Visio and Excel continue to open in the browser?

  7. Great post! You saved my life!

  8. I love how you still write and share about your day and experiences! You feel like such a real, nice, and humble person because of this!

  9. It's looking very good article It's help me lot. Can i apply Item-level Permissions to the document library also. It is not available in OOB but powershell. I want to apply the same Item-level Permissions to the library.

  10. thank you very helpful article. allow me to join to share health articles with your article hopefully useful.

    Cara Mengobati Rematik

  11. تقوم الأيدي العاملة بمهمة مركز الأثاث بالكامل و تغليفه على نحو جيد لحمايته من أي ضرر خلال عملية النقل .
    تعتمد المؤسسة على فنيين متخصصين في ميدان نقل الأثاث لهم القدرة الكاملة على فك وتركيب جميع أجزاء الأثاث في القاعات المتغايرة .
    شركة نقل عفش
    شركة نقل اثاث من الرياض الى جدة

    شركة نقل عفش من الرياض الى جدة
    شركة نقل عفش بخميس مشيط

  12. The information you shared was useful. You have brought up a very wonderful points , regards for the post.
    canon printer support | dell printer support