Monday, February 7, 2011

Working with Lists and Schemas

I thought I would put up a quick post about retrieving list schema definitions via powershell while at the SPTechCon 2011 in SF this week. I've been working on some new Metadata functionality with JQuery and the SPServices Library (http://spservices.codeplex.com/ courtesy of Marc D Anderson), and realized that it's a real pain in the a** working with Managed Metadata Columns in SharePoint.

Here's a quick reference for grabbing the XML Schema of a list definition so you can get to internal field names, column definitions, and the Taxomony Ids required for interacting with the TaxonomyClientService.

$site = Get-SPSite http://[Site Url]
$web = $site.OpenWeb() - note: leave the value blank for the top-level web, or specify "/web url" between the parentheses to retrieve a specific web
$list = $web.Lists["List Name"]
$list.SchemaXML | Out-File C:\Temp\schema.xml


Now you should have an xml file containing the schema of your list. Open the file in your XML editor of choice, and have a blast locating the attributes you need.



2 comments:

  1. I liked your article, I will share your article to everyone!!



    ________________________________________________________________________
    WoW gold|Diablo 3 Gold|RS Gold|GW2 Gold

    ReplyDelete
  2. Its very useful tips, thanks for sharing it to us.


    ______________
    Guild wars 2 gold
    Click here

    ReplyDelete