Site Column & List Column Default values
-
29-12-2020 - |
Question
I have to find the default values of Site columns and Library/list columns using PowerShell script. The site contains 8 to 10 libraries and the default values are different on each library hence I need to get the default values for the columns in different libraries as well as the site column. The following code gives only the Site columns, I need library column details as well.
.$defvalue = $field.DefaultValue.
Can anyone please help me with the ways to collect this information.
Solution
Get Default value for Site Column:
$web= Get-SPWeb http://siteurl
$field = $web.Fields["FieldName"]
$devaultvalue = $field.DefaultValue
Get Default value for List / Library Column
$web= Get-SPWeb http://siteurl
$list = $web.Lists["listname"]
$FieldName = $list.Fields["FieldName"]
$defaultvalue= $FieldName.DefaultValue
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange