SharePoint 2010: how to import/export metadata terms

Using PowerShell script to achieve this

  • Service account required to have BULKAdmin permission in SQL database, otherwise it will be having exception: You do not have permission to use the bulk load statement
  • Make sure the service account will have the permission to access to the file path, otherwise it will be having exception:  Access to the path ‘C:\Temp’ is denied.

Here is the PowerShell Script to Import and Export terms:

#Update these according to what is created/shown in central administration

$proxyName = “Managed Metadata Service”
$serviceName = “Managed Metadata Service”
$filePath = “C:\Temp\terms.bak”

#Get the Metadata Service Application

$svc = Get-SPServiceApplication | ?{$_.TypeName -eq “Managed Metadata Service” -and $_.DisplayName -eq $serviceName}

#Use this to Export

Export-SPMetadataWebServicePartitionData $svc.Id -ServiceProxy $proxyName -Path $filePath

#Use this to Import

Import-SPMetadataWebServicePartitionData $svc.Id -ServiceProxy $proxyName -Path $filePath -OverwriteExisting

This only works in a single farm , all in one box solution, there will be issues coming up when it’s a multi-server situation.

You will get the following exception if that’s the case:

Cannot bulk load because the file “C:\Temp\terms.bak” could not be opened.

The workaround for this is:

  1. copy the terms.bak to the SQL server box,  and grant read and write permission with the service account in that folder temporarily
  2. Replace the file path to use a network path, for example “\\servername\c$\temp\terms.bak”
Advertisements

2 thoughts on “SharePoint 2010: how to import/export metadata terms

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s