In a Sharepoint 2010 Enterprise site. I've got a library containing documents pertaining to foreign countries. So I have folders for Argentina, Chile, etc.. The list items have a text field called Country which I'm trying to set.

I don't want to go through all the folders and set the default Country field to the same as the containing folder, so I'm writing a Powershell script...

    $lib = $web.Lists["dguide"]
    $metadataDefaults = New-Object -TypeName Microsoft.Office.DocumentManagement.MetadataDefaults -ArgumentList $lib
    $Thisfolder = $web.GetFolder("dguide/$Foldername")
    $metadataDefaults.SetFieldDefault($Thisfolder,"Country", $Foldername)  


    $folderDefaultValue = $metadataDefaults.GetFieldDefault($Thisfolder, "Country")
    "the value is now $folderDefaultValue"

Even though the value appears to change, it doesn't change in practice. The folder gets a little green 'settings' gear suggesting customization, but the value is "" for country.

So what am I doing wrong?

  • So, nothing, eh? Jun 5, 2015 at 9:32
  • try just updating $metadataDefaults. I don't think you need to update the folder or the library, which sometimes may cause undesired effects Jul 13, 2015 at 16:25

2 Answers 2


According to this post the folder path is case sensitive.

The poster OlegO states:

For example if your folder is /Shared Documents/Abc and you use /Shared Documents/abc or /shared documents/Abc or /SHARED DOCUMENTS/ABC to execute MetadataDefaults.SetFieldDefault method.

The SetFieldDefault method returns true, but your settings wouldn't be applied to folder.

Additional problem if you get SPFolder from "wrong" url http://site/shared documents/abc and then use SPFolder in MetadataDefaults.SetFieldDefault, your settings wouldn't be applied to folder, also.

Does that help?


I found that I had to set the server relative path myself. Passing in the folder object didn't work but was passing back true.

It worked just fine when I set the full path as below,

$metadataDefaults.SetFieldDefault("/hr/EmployeeFiles/Mike/Administration", "DocumentCategory", $value) 

I got a hint from Setting Location Based Column Defaults with SPServices

Going to work on calculating the path programmatically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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