Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Using the following code I should be able to access the Taxonomy Term Stores:

$site = new-object Microsoft.SharePoint.SPSite("http://localhost")
$session = new-object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
$session.TermStores.Count

Yet the TermStore count is always 0. I know I have Term Stores and Term Groups and Terms because I'm able to tag items using the terms and view them in the Term Store Management Tool. For the SPSite I have tried localhost, the actual computer name, and even the Central Admin site.

Based on my research this shouldn't be that difficult.

http://msdn.microsoft.com/en-us/library/ee574969.aspx

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.taxonomysession.aspx

http://geeklit.blogspot.com/2009/12/using-sharepoint-term-stores.html

http://davidfrette.wordpress.com/2010/03/31/million-terms

Can you please spot what I'm doing wrong?

share|improve this question
add comment

3 Answers

The account you are running powershell may not have permission - you will notice that the session lists the service as offline. Check the Administrators for Metadata Service Application and also check Connection Permissions for Metadata Service Application (which is what fixed it for me).

share|improve this answer
add comment
up vote 3 down vote accepted

My Managed Metadata Application Proxy was not a part of the default proxy group. After running the following command $session.TermStores.Count now returns 1! Yay!

Set-SPMetadataServiceApplicationProxy -Identity "Metadata Service Application Proxy" -DefaultProxyGroup
share|improve this answer
    
Thanks for following up! –  Rob Wilson Jul 20 '10 at 2:30
    
Please note, the comments here (regarding Application Proxy and Permissions) worked for me only after I rebooted my machine. –  metaomniliquant Mar 6 '12 at 20:36
add comment

If you look at the second MSDN link you listed, you'll see that the example pulls the session's TermsStores object into a TermStoreCollection and checks the count from there. I wonder if that would solve your problem...

share|improve this answer
    
That's a good point. Unfortunately getting a reference to the TermStoreCollection still results in 0 entries. $site = new-object Microsoft.SharePoint.SPSite("localhost") $session = new-object Microsoft.SharePoint.Taxonomy.TaxonomySession($site) $stores = $session.TermStores $stores.count 0 –  Corbett Jul 19 '10 at 12:41
    
This guy is having the same trouble: go4answers.com/Example/…. What URL does the TaxonomySession's site need to be? Central Admin? –  Corbett Jul 19 '10 at 16:33
add comment

Your Answer

 
discard

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.