0

I want to create a new term using PnP for our sharepoint online tenant, so i tried this PnP script:-

PS C:\Windows> Connect-PnPOnline -Url https://****-admin.sharepoint.com
PS C:\Windows> New-PnPTerm -TermSet "T Group" -TermGroup "Customers" -Name "Active IT" -Id 53385e78-e4c3-4f26-baac-bf7c832ec7d2

But i got this error:-

New-PnPTerm : Specified argument was out of the range of valid values. Parameter name: index At line:1 char:1 + New-PnPTerm -TermSet "T Group" -TermGroup "Customers" -Name "Active IT... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (:) [New-PnPTerm], ServerException + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Taxo nomy.NewTerm

so can anyone advice on this?

I also tried to pass the Lcid (although i think i do not have to, if i want to use the defualt) + i reorder the parameters as mentioned on this link https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/new-pnpterm?view=sharepoint-ps, but i am still getting the same error:-

New-PnPTerm -Name "Active IT" -TermSet "T Group" -TermGroup "Customers"  -Id "53385e78-e4c3-4f26-baac-bf7c832ec7d2" -Lcid "1033"
3
  • Are the ID just a random generated string? According to the documentation, this must be a valid GUID and not a string. If you really want that number, try convert it to a GUID and then create a new term. social.technet.microsoft.com/Forums/windowsserver/en-US/… – Christoffer Apr 12 '19 at 14:43
  • @Christoffer the -Id is a GUID number i got from our on-premises farm, as i want the on-premsies term and the online term to have the same GUID.. – John John Apr 12 '19 at 14:44
  • @Christoffer also even if i remove the -Id as follow New-PnPTerm -Name "Active IT" -TermSet "T Group" -TermGroup "Customers" .. i will still get the same error New-PnPTerm : Specified argument was out of the range of valid values. – John John Apr 12 '19 at 14:47
1

Make sure the TermSet and TermGroup specified already exist in the Term Store.

This works for me if both are already present:

New-PnPTerm -Name "Active IT" -TermSet "T Group" -TermGroup "Customers" -Id "53385e78-e4c3-4f26-baac-bf7c832ec7d2" -Lcid "1033"

You can use the New-PnPTermGroup and New-PnPTermSet to create the term group and termset before creating the new term.

2
  • your script worked fine... and do you think there is any problem if we use an on-premises term GUID to add a new term inside SP online using the on-premises GUID? as in my case i want the on-premsies and online term to have the same GUID – John John Apr 12 '19 at 23:22
  • 1
    I don’t see any reason that should be a problem. The GUID only has to be unique in the term store. – Vardhaman Deshpande Apr 13 '19 at 8:37
0

You have to check, which languages are allowed in your Term store.

Replace your tenant name in the following URL and then open it in a browser: https://[yourTenantName]-admin.sharepoint.com/_layouts/15/online/AdminHome.aspx#/termStoreAdminCenter

In my case, the term store had only English (lcid 1033) set as default language and no additional Working language was defined.

When running the PowerShell, it automatically took lcid 1031 (German) as default, so it failed. When I tried setting manually lcid 1031, it still failed. When I set lcid manually to lcid 1033, the command succeeded, but that was not, what I wanted.

The solution was to got in the term store administration and add German as a working language. Afterwards, I was also able to run the command without setting lcid. It is also possible to change the default Term Store language afterwards.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.