How to Call Sharepoint Taxonomy in Powershell

I have the following bit of PowerShell, which returns a list of all the Departments stored in SharePoint’s managed metadata :

Add-PSSnapin Microsoft.Sharepoint.Powershell

# Get the site collection
$sitecollection = Get-SPSite 'http://mysharepointsite/'

# Get the term store id
$taxsession = Get-SPTaxonomySession -Site $sitecollection

# Change to the requierd service name
$termstore = $taxsession.TermStores["Managed Metadata Service"] 
$termstore.id

# Get the term set id
$termstoregroup = $termstore.Groups["People"]
# Change to your term set name
$termset = $termstoregroup.TermSets["Department"]
$termset.id

$departments = $termset.id.name
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s