I would like to add some new tables to my SPO site through using PowerShell and a site script. One of the columns is a Lookup type. According to this, I should be able to use the action addSPLookupFieldXml to add this column. However, when I run the Add-SPOSiteScript command in PowerShell, I receive this error:

Add-SPOSiteScript : This action isn't recognized: addSPLookupFieldXml
At line:1 char:1
+ Add-SPOSiteScript -Title "Add Test List" -Content $site_script -Desc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-SPOSiteScript], ServerException
    + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.AddSP

The relevant part of my site script contains:

         "verb": "addSPLookupFieldXml",
         "schemaXml": "<Field Type=\"Lookup\" ID=\"{9265de7a-db84-4357-b975-f83c7a7d724a}\" DisplayName=\"Test Lookup Column\" Required=\"TRUE\" EnforceUniqueValues=\"FALSE\" Group=\"Test Group\" ShowField=\"ID\" UnlimitedLengthInDocumentLibrary=\"FALSE\" RelationshipDeleteBehavior=\"None\" StaticName=\"TestColumn\" Name=\"TestColumn\"></Field>",
         "targetListName": "OriginalTestList",
         "addToDefaultView": true

I can create and modify lists with no issues if I exclude this action, but I require a Lookup column for my list. Does anyone have any advise?

  • Which version of SharePoint online PowerShell are you using? Try updating to latest version & see if it works. Sep 21 at 11:53
  • @GaneshSanap I updated and when I check, the version is Microsoft.Online.SharePoint.PowerShell 16.0.21513.12000 Microsoft.Online.SharePoint.PowerShell 16.0.21513.0 I tried running the site script again and get the same error
    – Easty12345
    Sep 21 at 12:24

Your Answer

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

Browse other questions tagged or ask your own question.