2

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.

6

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.