Wednesday 3 February 2016

Import Term Store with Same GUID - SharePoint 2013

Recently i was tasked to import the term-store to different environment and below are the steps to Import TermStore with same GUID as source system.

 To Export


Add-PSSnapin Microsoft.SharePoint.Powershell
 $metadataApp=
Get-SpServiceApplication | ? {$_.TypeName -eq "Managed Metadata Service"}
 $mmsAppId = $metadataApp.
Id
$mmsproxy = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq "Managed Metadata Service Connection"}
 
Export-SPMetadataWebServicePartitionData -Identity $mmsAppId -ServiceProxy $mmsproxy -Path "C:\TermStore.cab”

To Import

Add-PSSnapin Microsoft.SharePoint.Powershell
 $metadataApp= 
Get-SpServiceApplication | ? {$_.TypeName -eq "Managed Metadata Service"}
 $mmsAppId = $metadataApp.
Id
$mmsproxy = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq "Managed Metadata Service Connection"}
Import-SPMetadataWebServicePartitionData -Identity $mmsAppId -ServiceProxy $mmsproxy -Path "\\SharedPath\TermStore.cab" -OverwriteExisting;

Few issues you would face during import:

Import-SPMetadataWebServicePartitionData : Cannot bulk load because the file
"\\SharedPath\5460e56e7338462699857df67766a557\ECMGroup.dat" could not be opened. Operating system error code 5(Access is denied.). At line:1 char:1

Solution: Make sure account you are running the import script has "bulkadmin DB role".

Import-SPMetadataWebServicePartitionData : Cannot bulk load because the file "\\SharedPath\ed95fa1e4975464195b62f16f4de5ba9\ECMGroup.dat" could not be opened. Operating
system error code 3(The system cannot find the path specified.).
At line:1 char:1

or 

Import-SPMetadataWebServicePartitionData : Cannot bulk load because the file "\\SharedPath\18e85ecec7764f60a03ac0427e4eb1ba\ECMGroup.dat" could not be opened.
Operating system error code 5(Access is denied.).
At line:1 char:1

Solution:  SQL account is not able to extract the cab and do bulk upload. so place the cab file in sql server box networkshare.