PowerShell code for looking up document properties

If you want to use the SPWeb.Files.Add() method that allows you to pass in a HashTable of metadata for the document, you will need to use the internal name of the metadata field, not the display name.   Here's a PowerShell script to get that for you quickly:


$web = Get-SPWeb http://intranet.sharepointdev.com
$list = $web.Lists["Shared Documents"]
foreach($item in $list.Items)
{
    $file = $item.File
    #output all the SPFile property names
    foreach($key in $file.Properties.Keys)
    {
        write-host("File Key: " + $key)
    }
   
    #output the associated item's fields
    foreach($field in $item.Fields)
    {
        write-host("Item Field: " + $field.InternalName)
    }
    break;
}

Comments

Popular posts from this blog

Programmatically Update Page Layouts

Microsoft Virtualilzation Headaches

ERROR: Failed to create feature receiver...