How do I import a CSV file to metadata service using PowerShell? The CSV file has 500 rows and seven levels in it (Importing of term store).

1 Answer 1


This is the PS script I'm using:

    Param([string]$CentralAdminURL, [string]$TermsCSV, [string]$ADGroup)

    # loading the term store
    $site = Get-SPSite -Identity($CentralAdminURL)
    $session = new-object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
    $termstore = $session.TermStores[0]

    # Create a Taxonomy Group
    # I first create a Term Group
    $termGroup = "MY MM Group"
    $group = $termstore.CreateGroup($termGroup)
    # Import Taxonomy "Know How"
    # Create an instance of ImportManager
    $Importer = $termstore.GetImportManager()
    $varImported = ""
    $varMessages = ""
    $TermSetReader = [System.IO.File]::OpenText($TermsCSV)

    # Syntax: ImportTermSet(TermGroup, TextReader, out isImported, out errorMessage)
    $termset = $Importer.ImportTermSet($group ,$TermSetReader, ([REF] $varImported), ([REF] $varMessages))
    Write-Host $varMessages
    Write-Host $varImported

adapted from the original at http://stevenderveaux.wordpress.com/2010/04/09/import-taxonomy-csv-file-via-powershell/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.