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
$list.Update()
}

#Dispose of the site object
$site.Dispose()

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)
image
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)
image
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)
image
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

image
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

image
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)
image
This command will enable the “Send e-mail when ownership is assigned” option:

$list.EnableAssignToEmail = $true
Attachments
(lists only)
image
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)
image
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…

53 comments:

  1. Do you have part3 already available?

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

    ReplyDelete
  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

    $web.getlistoftype("DocumentLibrary")

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

    ReplyDelete
  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")

    ReplyDelete
  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: http://get-spscripts.com/2010/11/add-and-remove-site-content-types-from.html

    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

    }

    ReplyDelete
  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?

    ReplyDelete
  7. Great post! You saved my life!

    ReplyDelete
  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!

    ReplyDelete
  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.

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

    Cara Mengobati Rematik

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

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

    ReplyDelete
  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

    ReplyDelete
  13. WinRAR Crack is a powerful archive manager for Windows. WinRAR 5.90 Final Crack is a powerful compression tool with many integrated additional functions to help you organize your compressed archives.WinRAR Crack

    ReplyDelete
  14. thanks for your post i have found the information that i want on your blog its such a nice theme .
    thanks for your infomative post .
    Free Full Pro Keys for Windows & Mac software

    Full Pro Keys

    ReplyDelete
  15. thanks for your post i have found the information that i want on your blog its such a nice theme .
    thanks for your infomative post .
    Free Full Pro Keys for Windows & Mac software

    Full Pro Keys

    ReplyDelete
  16. thanks for your post i have found the information that i want on your blog its such a nice theme .
    thanks for your infomative post .
    Free Full Pro Keys for Windows & Mac software

    Full Pro Keys

    ReplyDelete
  17. OmniSphere 2 Free is definitely a extensive software alternative for various wave kinds and features. It happens to be embedded that has a number of increased functions and features that helps customers recover sound efficiency. Together with the simplicity of browsing graphics and material, most current sounds and results can be quite easily navigated.

    ReplyDelete
  18. thanks for your post i have found the information that i want on your blog its such a nice theme .
    thanks for your infomative post .
    Free Download Oceanofgames for Windows & Mac software PC Games

    Ocean of Games

    ReplyDelete
  19. thanks for your post i have found the information that i want on your blog its such a nice theme .
    thanks for your infomative post .
    Free Download Oceanofgames for Windows & Mac software PC Games

    Ocean of Games

    ReplyDelete
  20. Air Jordan 4 Retro Black And Gold, Soccer canceled friendlies involving the men's and women's teams as well as youth national team training camps. And Mexico that was scheduled to start March 20 in Guadalajara. The CONCACAF Nations League semifinals and final in June have been canceled..

    Air Jordan Retro 6 Black And Blue, Distress Centre of Ottawa Region has been with you through thick and thin, and during these unsettling times with COVID 19, we continuing that support, 24/7, the agency wrote on its GoFundMe page. With many other organizations, we have experienced a financial burden related to COVID 19, while simultaneously experiencing a surge in demand for our services. GoFundMe had received $140 of its $50,000 goal when Reynolds chipped in, first with a of the GoFundMe tweet..

    Jordan 1 All Black Mid, Le'Veon Bell's total yards from scrimmage, touches and touchdowns decreased in his first season under Gase. After Gase's tenure with the Dolphins, players like Kenyan Drake and DeVante Parker reached career highs in total offensive yardage. The Jets need a star wideout, especially with the departure of Robby Anderson, but the targets may be inconsistent and inaccurate at times.

    Nanochips are sprayed by the gov using chemtrails; they also in gov food and medicine; so, eat food from your own garden. In case garden is destroyed by ice from the sky, have chickens for eggs and goats for milk (Paisios). Lipstick contains cells of aborted fetuses, dog fat, and placenta; human flesh is in McDonalds, Pepsi, toothpaste, antiaging, anticancer, vaccines, perfume, etc.; that why you should not be using anything that modern society has to offer. {tag: Stockx Yeezy Cloud White Reflective}

    L Brands has tried to broaden Victoria's Secret's appeal, hiring transgender and plus size models and adding two additional women to the parent company's board, which until recently was dominated by white men with a median age of 71. In November, the company canceled its televised fashion show, saying it was rethinking the format. The company's board of directors said in a statement that it's made "significant strides" in recent years in providing "a safe, welcoming, and empowering workplace" for its employees and remains "fully committed to continuous improvement and complete accountability.". {tag: Triple White Yeezy Footlocker}

    ReplyDelete
  21. thanks for your post i have found the information that i want on your blog its such a nice theme .
    thanks for your infomative post .
    Free Full Pro Keys for Windows & Mac software

    How4Crack


    ReplyDelete
  22. thanks for your post i have found the information that i want on your blog its such a nice theme .
    thanks for your infomative post .
    Free Full Pro Keys for Windows & Mac software

    How4Crack

    ReplyDelete
  23. thanks for your post i have found the information that i want on your blog its such a nice theme .
    thanks for your infomative post .
    Free Full Pro Keys for Windows & Mac software

    How4Crack

    ReplyDelete
  24. thanks for your post i have found the information that i want on your blog its such a nice theme .
    thanks for your infomative post .
    Free Full Pro Keys for Windows & Mac software

    How4Crack

    ReplyDelete