다음을 통해 공유


PowerShell to set up default value for Rich Text Field in SharePoint 2010

Started this morning with good question related to SharePoint 2010.

Hi there, do we have an option to update field items with default values? There are many ways to do it using Visual Studio.

List it's a document library and implemented using WSP solution.

 This has three description fields with different internal names and each has different languages like English, Dutch and Spanish. Good that we got some inputs from customers as well.

Lets start PowerShell ISE to explore the feasibility. We should ensure that we are not harming the existing items. That's the motive in my implementation.

$list = (Get-SPWeb "C").Lists |? {$_.Title -eq "Test List"}
$field = $list.Fields["Description"]
$field | GM

 Fine, now we have some foot prints - we have a property called DefaultValue. Let us safely play with that

$defaultValue = @"
Vision
Mission
Customer
"@
$list = (Get-SPWeb "http://hostheader.com/windows_test").Lists |? {$_.Title -eq "Test List"}
$field = $list.Fields["Description"]
$field.DefaultValue = $defaultvalue
$field.Update()