none
Using PowerShell Script, how do I copy the Term Store from source Site Collection to the target Site Collection in the SAME farm?

    질문

  • Hi,

    I am using Backup-SPSite to backup a site collection & then using Restore-SPSite to restore the site collection in a new web application in the SAME farm (SharePoint 2016 On-Premises).

    However, the Term Store from source Site Collection is not copied using Restore-SPSite to the target Site Collection. Error: "Error loading navigation: The Managed Navigation term set is improperly attached to the site" is displayed in Term Store Management Tool for the target Site Collection.

    Using PowerShell Script, how do I copy the Term Store from source Site Collection to the target Site Collection in the SAME farm?

    Please provide solution to this issue ASAP.

    Thanks in advance

    • 편집됨 Jack63_01 2018년 7월 13일 금요일 오후 12:04
    2018년 7월 13일 금요일 오후 12:01

모든 응답

  • Hi,

    1. Get the Default Site Collection Term Store via PowerShell:
    $site = Get-SPSite <site collection URL>
    $tx = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
    $termstore = $tx.DefaultSiteCollectionTermStore
    $termstore
    1. Get the term groups via PowerShell:
    $site = Get-SPSite <site collection URL>
    $tx = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
    $termstore = $tx.DefaultSiteCollectionTermStore
    $termstore
    Foreach ($termgroup in $termstore.Groups)
    {
                  $termgroup
    }
    1. Update the “SiteCollectionGroupID…” property and grant term group access as part of the restore operation.
    $site = Get-SPSite <site collection URL>
    
    $tx = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
    
    $termstore = $tx.DefaultSiteCollectionTermStore
    
    $web = $site.RootWeb
    
     # Link the restored site collection to the old local term group
    
    # If this script is executed immediately after a restore of the site collection, the property shouldn’t exist.  However, it is good to check for the existence of the property.
    
    $webProp = $web.GetProperty(“SiteCollectionGroupId<MMS GUID>”)
    
    If ($webProp –eq $null)
    
    {
    
                   $web.AddProperty(“SiteCollectionGroupId<MMS GUID>”, <term group ID – see script above to get this value>)
    
                   $web.Update()
    
    }
    
    Else
    
    {
    
                   # Property exists – remove/re-add the property
    
                   $web.DeleteProperty(“SiteCollectionGroupId<MMS GUID>”)
    
                   $web.AddProperty(“SiteCollectionGroupId<MMS GUID>”, <term group ID – see script above to get this value>)
    
                   $web.Update()
    
    }
    
     
    
    # Grant the restored site collection access to the old term store
    
    $group = $termstore.Groups | Where-Object {$_.id –eq “term group ID”}
    
    $group.AddSiteCollectionAccess($site.id)
    
    $termstore.CommitAll()
    
    $web.Dispose()
    
    $site.Dispose()

    Here is the thread for your reference.

    https://blogs.msdn.microsoft.com/bettertogether/2014/10/04/site-collection-backuprestore-when-using-local-term-groups/

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018년 7월 16일 월요일 오전 2:12