SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a powershell script that allows me add metadata column in SharePoint list. Thanks

share|improve this question
Do you already have site columns created of type managed metadata? or you want to create that also? – Ashish Patel Jan 27 '12 at 17:01

The code below is a mix of some PS code i had laying around and stuff translated from C# on the fly (so there might be some errors in there :-D)

Also, this code creates a fullblown site column in the SPWeb and adds that to the list

To start, you need a reference to the termstore, i've written 2 functions that use CA and the metadata service app's type to get a standard installation's Termstore:

function Get-TaxonomySessionDefault()
  $centralAdmin = Get-SPWebApplication -IncludeCentralAdministration | Where {$_.IsAdministrationWebApplication} | Get-SPSite
  $session = new-object Microsoft.SharePoint.Taxonomy.TaxonomySession($centralAdmin)
  return $session

function Get-TermStoreDefault()
  $session = Get-TaxonomySessionDefault
  $serviceApp = Get-SPServiceApplication | Where {$_.TypeName -like "*Metadata*"}
  $termStore = $session.TermStores[$serviceApp.Name]    
  return $termStore;

now you can use these methods to access the termstore and get a reference to a TermSet to which to bind your new field

function Get-TermSet([string]$groupName, [string]$termSetName)
  $termStore = Get-TermStoreDefault
  return $termStore.Groups[$groupName].TermSets[$termSetName]

and using that function, we can create a function that creates a managed metadata site column in an SPWeb

function Create-TaxonomyField(
  $termSet = Get-TermSet $termStoreGroupName $termSetName

  $taxonomyField = $web.Fields.CreateNewField("TaxonomyFieldType", $displayName)

  $taxonomyField.SspId = $termSet.TermStore.Id
  $taxonomyField.TermSetId = $termSet.Id
  $taxonomyField.AllowMultipleValues = $false
  $taxonomyField.Group = $fieldGroup
  $taxonomyField.StaticName = $staticName
  $taxonomyField.ShowInEditForm = $true
  $taxonomyField.ShowInNewForm = $true
  $taxonomyField.Hidden = $false
  $taxonomyField.Required = $false



  return $taxonomyField

Now all we need is a function to add the field to a list

function Add-FieldToList(
  $list = $web.Lists[$listTitle]

EDIT: I am a big fan of PowerGUI, a great (free!) tool to write, test and debug(!!) your powershell scripts!

EDIT: I have modified some lines to make it work

share|improve this answer
Thank you colin it helped me and i have done it..:-) – vikram06 Jan 30 '12 at 15:06

There is a neat blog post where this is mentioned with detailed steps and snapshots. Please refer -

EDIT: There is also a blog post which shows how managed metadata column is added using Client Object model in SharePoint 2010. Replace them with Powershell scripts and you shall get your result -

share|improve this answer
Hi Deepu Nair Thanks for the reply but i'm looking for adding simple metadat columns to a list.The above link is about metadta navigation settings.Please Kindly help me out. – vikram06 Jan 27 '12 at 16:53
Thank you Nair.I will try that out.Thanks alot... – vikram06 Jan 27 '12 at 18:22
Hi Nair tried to do with the code but having some issue my list is creating the columns except the metadata column which is is the script i used – vikram06 Jan 27 '12 at 19:10

Sorry for the self promotion, but I have a post that shows you how to create a Managed Metadata column & add it to an existing list. Downloadable project as well:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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