Fetch default values of folders with PowerShell

If you want to fetch folder default values with PowerShell you need to call the Method Microsoft.Office.DocumentManagement.MetadataDefaults.GetFieldDefault.


The following PowerShell script will show you how to use this method:


add-pssnapin microsoft.sharepoint.powershell -ea silentlycontinue

$web = get-spweb http://server/sites/thesite
$lib = $web.Lists["Shared Documents"]


$metadataDefaults = New-Object -TypeName Microsoft.Office.DocumentManagement.MetadataDefaults -ArgumentList $lib

foreach ($oneFolder in $lib.Folders) {
    Write-Host ("Folder: {0}" -f $oneFolder.Url)
    $folderObject = $web.GetFolder($oneFolder.Url)
    $folderDefaultValue = $metadataDefaults.GetFieldDefault($folderObject, "ColumnName")
    Write-Host ("  Default Value: {0}" -f $folderDefaultValue)


Comments (1)

  1. shane says:

    Great posting. That really helped me to get my issues solved. Strange API at this point.

    Thanks for your work here!

Skip to main content