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"
  • 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 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.. – SharePoint TestDev Apr 12 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. – SharePoint TestDev Apr 12 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.

  • 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 – SharePoint TestDev Apr 12 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 at 8:37

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.