Thursday, September 13, 2012

Powershell script to Export and Import Managed Metadata Termstore across SharePoint farms while still retaining its GUIDs

While migrating your site collections from one farm to the other, Managed Metadata termsets being used and stored in lists and libraries for various site collections would reference to the GUID’s of the original managed metadata term store. The site columns themselves, would reference the GUID of the term sets of the source managed metadata service. Hence, it becomes difficult to migrate the various site collections to the new farm. In this situation, we run the risk of making the existing managed metadata columns being orphaned for the source site collection to be migrated.

Below mentioned PowerShell script Exports and Imports Managed Metadata termstore still retaining its GUID's (sspId's- used internally by the Termstore) and referred by Managed metadata columns in list/library.

#Export Managed Metadata Taxonomy Name

$managedMetadataAppSource = “4a867ce5-d9ee-4051-8e73-c5eca4158bcd”; #this sets the exporting MMS ID
$mmSourceProxy = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq "Managed Metadata Service Connection"};
Export-SPMetadataWebServicePartitionData -Identity $managedMetadataAppSource -ServiceProxy $mmSourceProxy -Path "C:\ExportManagedMetadata\locationexportfile.bak";

#Import Managed Metadata Taxonomy Name

$managedMetadataAppTarget = "d045d3ce-e947-4465-b039-0dfbbe24fb22"   #this sets the importing MMS ID
$mmTargetProxy = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq "Managed Metadata Service Connection"};
Import-SPMetadataWebServicePartitionData -Identity $managedMetadataAppTarget -ServiceProxy $mmTargetProxy -Path "C:\ImportManagedMetadata\locationexportfile.bak" -OverwriteExisting;


  1. Mehul,

    this is great stuff. Thanks for sharing this.

    Vadim Tabakman

  2. Using these cmdlets I can quickly exports conditions from one environment, such as development, to another environment, such as my analyze environment.This prevents the need to have back-up and recover the data source associated with the term store.

  3. it it true that the bak file needs to be stored on the local sql drive for the insert to happen? Any special permissions needed for the managedmetadata service account in sql?

  4. Thanks for the post! got the following error:
    Export-SPMetadataWebServicePartitionData : The current user has insufficient permissions to perform this operation.
    What permission should i have?
    Thank you!

  5. This looks very similar to

    EZ, you likely need either permission on the MMS service application, or be a term store administrator defined in the UI.

  6. Will this work for SharePoint 2013?

  7. It does work with SharePoint 2013.

  8. Will this work with SharePoint Online (Office 365)?

  9. Hi, I am using Managed navigation in SPS 2013, I am trying to restore my site from Dev. server to staging server. i have used the above command and it does not work, i don't see anything in term store in target server. One thing i have noticed that backup file size is 7k when used the export command but when i take the backup on managed DB from SQL server directly, the backup file size is 3799k. let me know if i am missing anything

  10. Is this backup includes site columns and content types? or just TermStore data?

  11. what does Managed Metadata Service Connection look like? is this a connection string? where do I find this? I'm a newbie when it comes to SharePoint development and I need to migrate a term set, that took 3 hrs to finalize, to another site collection

  12. The above scripts work fine but in my scenario i need to keep existing MMS Termstore intact and bringing termstore from other environment as well i-e i want to merge term stores of existing and new environment. Now, in my case these scripts override existing term stores. If i exclude -overrideexisting parameter then import script fails. I desperately need help in this regard

  13. Sending a SMS or MMS is a standout amongst the most well-known assignments performed on the Twilio Platform. Communicating something specific is as basic as POST-ing to the Messages asset, however since it's a typical activity it merits strolling through in point of interest underneath.
    Twilo SMS

  14. Basic E-Commerce Shopping Cart Plugin to offer advanced/physical items from your wordpress site through PayPal.
    Wordpress Plugins For Sale

  15. I had multiple stores and this helped me:
    I changed the GUID / ID

    #Export Managed Metadata Taxonomy Name

    $managedMetadataAppSource = “f9273334-c733-486f-a876-5333dc658c36”; #this sets the exporting MMS ID
    $mmSourceProxies = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq "Managed Metadata Service Connection"};
    foreach($mmSourceProxy in $mmSourceProxies)
    Export-SPMetadataWebServicePartitionData -Identity $managedMetadataAppSource -ServiceProxy $mmSourceProxy -Path "G:\Terms\$mmSourceProxy.Displayname_exportfile.bak"