I am using PnP (PnP PowerShell overview) to get the term. Verify you are using the latest version. Check out this documentation to get the Client Taxonomy Term members. For the on-premise see here. Not sure the differences but always check these documentations dependent on your environment. (online or on-premise)
Method 1:
#SharePoint Online tenant $orgName="https://contoso.sharepoint.com" try { write-host "Logging-in using SPO" $credFMS = Connect-PnPOnline -Url $orgName -SPOManagementShell write-host "Logged-in" } catch { write-host "Logging-in using WebLogin" $credFMS = Connect-PnPOnline -Url $orgName -UseWebLogin write-host "Logged-in" } #static values to test $entityGuid="70bad89b-173c-48e4-b640-2873a3a76179" $entityName="TermNameTest" $entityType="Managed Account" #Gets the term store based on the connection. Since we are connected to the root site collection, it will get the root site collection Term Store $termStore=Get-PnPSiteCollectionTermStore $sourceTermSetName = "TermSetSourceTestValue" $targetTermSetName = "TermSetTargetTestValue" $sourceTermGroupName = "TermGroupTestValue" $targetTermGroupName = "TargetTermGroupName" # Check if it exist first. "id" on the Where could be replaced with "Name" if you know the name of the term Where name -Name -eq $entityName $sourceTerm = Get-PnPTerm -TermSet $sourceTermSetName -TermGroup $sourceTermGroupName | Where id -eq $entityGuid if($sourceTerm.Count -gt 0) { #Found! - Reuse the term #Reuse term will place term under termset $targetParentTerm = Get-PnPTerm -Identity $entityType -TermSet $targetTermSetName -TermGroup $targetTermGroupName -Recursive $reuseTerm = $targetParentTerm.ReuseTerm($sourceTerm, $True) $termStore.CommitAll() }
Method 2: Even though the above worked for me, alternatively you can do the following using CSOM with PnP
#*** Connection / ****# #Locate where your module files are located $PathModule="C:\Program Files (x86)\SharePointPnPPowerShellOnline\Modules\SharePointPnPPowerShellOnline" Add-Type -Path "$PathModule\Microsoft.SharePoint.Client.dll" Add-Type -Path "$PathModule\Microsoft.SharePoint.Client.Runtime.dll" Add-Type -Path "$PathModule\Microsoft.SharePoint.Client.Taxonomy.dll" $urlRoot="https://Contoso.sharepoint.com/" $connectRoot=$null try { write-host "Logging-in to $urlRoot using WebLogin" #return connection to this variable using the -ReturnConnection parameter # '-UseWebLogin' is used for browser log-in. Typically for multi-factor authentication environments $connectRoot = Connect-PnPOnline -Url $urlRoot -ReturnConnection -ErrorAction Stop -UseWebLogin write-host "Logged-in" } catch { write-host "Unable to login" #Exit script if unable to connect return; } #Get the current context $Context = Get-PnPContext $sourceGroupName="SourceGroupNameSample" $targetGroupName="TargetGroupNameSample" $sourceTermSetName="SourceTermSetNameSample" $targetTermSetName="TargetTermSetNameSample" #Static $sourceTermEntityName="SourceTermNameSample" $targetCategoryTerm="SourceParentTermNameSample" $targetEntityTypeTerm="SourceChildTermNameSample" #Taxonomy Session $MMS = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($Context) $Context.Load($MMS) $Context.ExecuteQuery() #Retrieve Term Stores $TermStores = $MMS.TermStores $Context.Load($TermStores) $Context.ExecuteQuery() #Term Store $TermStore = $TermStores[0] $Context.Load($TermStore) $Context.ExecuteQuery() #Source Group $sourceGroup = $TermStore.Groups.GetByName($sourceGroupName) $Context.Load($sourceGroup) $Context.ExecuteQuery() #Target Group $targetGroup = $TermStore.Groups.GetByName($targetGroupName) $Context.Load($targetGroup) $Context.ExecuteQuery() #Source TermSet $sourceTermSet = $sourceGroup.TermSets.GetByName($sourceTermSetName) $Context.Load($sourceTermSet) $Context.ExecuteQuery() #Source Term $sourceTerm = $sourceTermSet.Terms.GetByName($sourceTermEntityName) $Context.Load($sourceTerm) $Context.ExecuteQuery() #Create a term $TermAdd = $sourceTermSet.CreateTerm("NewTerm436",1033,[System.Guid]::NewGuid().toString()) $Context.Load($TermAdd) $Context.ExecuteQuery() #Get the Target Term Set $targetTermSet = $targetGroup.TermSets.GetByName($targetTermSetName) $Context.Load($targetTermSet) $Context.ExecuteQuery() #Get the Parent Term $targetCategoryTerm = $targetTermSet.Terms.GetByName($targetCategoryTerm) $Context.Load($targetCategoryTerm) $Context.ExecuteQuery() #Get the Child Term $targetTypeTerm = $targetCategoryTerm.Terms.GetByName($targetEntityTypeTerm) $Context.Load($targetTypeTerm) $Context.ExecuteQuery() #Reuse Term to the Target Child Term $targetTypeTerm.ReuseTerm($sourceTerm, $True) $Context.Load($targetTypeTerm) $Context.ExecuteQuery() # Create Single Label $sourceTerm.CreateLabel("LabelTest214",1033,$False) #Create multiple Labels $sourceTerm.CreateLabel("Test236",1033,$False) $sourceTerm.CreateLabel("Test237",1033,$False) #$Context.ExecuteQuery() # ExecuteQuery could be use here but since its called in the next lines, no need to call it now #Get the labels collection $sourceTermLabels = $sourceTerm.Labels $Context.Load($sourceTermLabels) $Context.ExecuteQuery() for ($i = 0; $i -lt $sourceTermLabels.Count; $i++) { write-host "Label Name: "$sourceTermLabels[$i].Value " / Is Default: " $sourceTermLabels[$i].IsDefaultForLanguage } Write-Host "End"