How To Connect SharePoint Managed Metadata Using PowerShell Script

Welcome to an a blog on how to connect SharePoint managed metadata, using PowerShell script. In our projects, we are sometimes required to retrieve the data from SharePoint managed metadata DB and use it in our projects.
We will see a very simple executable script, which will allow you to connect to SharePoint managed metadata database very quickly and efficiently.


  1. Open Windows PowerShell modules as an administrator.

  2. Paste the code, mentioned below as .ps1 file and execute it.


  1. #Add the PowerShell snap in code  
  2. Add-PSSnapIn Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-Null  
  3. #Provide a site collection to load the metadata properties from the SharePoint Central Admin where you metadata Database is connected  
  4. $siteCollectionUrl = "http://devlink /"  
  5. $site =new-object Microsoft.SharePoint.SPSite($siteCollectionUrl)  
  6. #Get the Taxanomy  
  7. $session = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)  
  8. #Get the Termstore  
  9. $termStore = $session.TermStores[0]  
  10. #Provide the term store group you want to load and get connected  
  11. $group = $termStore.Groups["Test"]  
  12. #Provide the termset you want to load  
  13. $termSet = $group.TermSets["Test1"]  
  14. #Get all the desired terms.  
  15. $terms = $termSet.GetAllTerms()  
  16. Write-Host "SharePoint Connected"  


  • Site Collection URL.
  • Name of the Term Store Group.
  • Name of the Term set.

The parameters, mentioned above are required from your end, while connecting to the metadata database. Once you get the correct parameters and execute the script, you will get a message “SharePoint Connected”.

Here, we are using the term group Test and trying to fetch the term set called as Test1. Similarly, you can use the script to connect any term group or term set, as per your requirement.

This connection can be used to view or edit the data in any metadata Service database. Here, in this article, we saw how to connect SharePoint managed metadata database, using PowerShell script.