How To Connect SharePoint Managed Metadata Using PowerShell Script

Welcome to an article on how to connect SharePoint Managed Metadata using PowerShell script. In our projects we sometimes require to fetch 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 the SharePoint Managed Metadata database very quickly and efficiently.


  1. Open Windows PowerShell Modules as an Administrator.

  2. Paste the following code 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 above parameters 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 data in any Metadata Service Database. Here in this article we saw how to connect SharePoint Managed Metedata Database using PowerShell Script.