Sunday, September 23, 2012

List the "vti_" properties using PowerShell

Every file/document in SharePoint possess some meta-info. It is stored in hashtable presented by SPFile.Properties property. Most of the properties start with "vti_". We cannot write the "vti_" properties as they are read-only.

But we can use this property-bag store custom meta-property for the file. We can manage the custom properties using below method:
  • SPFile.AddProperty
  • SPFile.SetProperty
  • SPFile.GetProperty

SPFile.CustomizedPageStatus property determines the customization status of wiki page or page layout using below properties.
  • vti_setuppath
  • vti_hasdefaultcontent
Different SharePoint objects has the hashtable based property to store these kind of properties. e.g SPWeb.AllProperties. SPWeb.AllProperties["__PagesListId"] stores the GUID value of "Pages" library created on activating publishing feature.

Changing the UIVersion of migrated sites automatically updates the master page to appropriate UIVersion. This is possible because of the SPWeb.AllProperties. It stores the master page details related to each UIVersion.

PowerShell script to list the "vti_" properties of a file.

$web=Get-SPWeb <webSite URL >
$list=$web.Lists["Site Pages"]
foreach($item in $list.Items)
{
    $item.File.Name
    Write-Host "**********"
    foreach($key in $item.File.Properties.Keys)
    {
        Write-Host $key "=" $item.File.Properties[$key]
    }
    Write-Host "------------------*****---------------------------"
}

PowerShell script to list "vti_" properties of web site.

$web=Get-SPWeb <webSite URL >
foreach($key in $web.AllProperties.Keys)
{
     Write-Host $key "=" $web.AllProperties[$key]
}

Have a look!
Post a Comment