Tuesday 28 April 2015

Update Managed Metadata Term Store Admin using PowerShell


Scenario: After I restore managed metadata service application database from a different environment I was able to successfully attach it with my existing MMS Application and all the terms came up fine. Two other site collection also came from same environment and attached terms were displaying fine on sites as well after restore.
Issue: I notice I was not able to create new terms (drop down in term set & groups was not visible) even after changing the MMS administrator from Central Administration several times it was not working as expected . Reboot and IIS Reset did not work.
Resolution: I use Power-Shell script to change MMS administrator. Below is script that will allow you to do same and few other things.
$TaxonomySite = Get-SPSite http://Yoursiteurl
$TaxonomySession = Get-SPTaxonomySession -site $TaxonomySite
$TermStore = $TaxonomySession.TermStores[0]
Note: At this point you can run TaxonomySession.TermStores[0] and it will show you ID of your managed metadata service application and also show you the Groups name so you can check if you have selected the right URL on the first line. In my case I was using global term set and it was shared with 2 other site collections, so I believe any Site URL will work in the first command

To add new term store administrator run this command and it will automatically remove the existing one.
$TermStore.TermStoreAdministrators
$TermStore.AddTermStoreAdministrator(“i:0#.w|Domain\NewAdministrator”)
$TermStore.CommitAll()
 To check the administrator name you can sue this command:
$TermStore.TermStoreAdministrators.

No comments:

Post a Comment