Create SharePoint Site Template via PnP Error: Null value in createSiteColumnXml

Occasional Contributor

I am trying to create a a site template that shows up in the 'From Your Organisation' option when applying a template to a site. I understand that the only way to do this these days is via PnP. I have no idea what I'm doing, so I have followed the guides from Microsoft:

Get started creating SharePoint site templates and site scripts | Microsoft Docs

Get-SPOSiteScriptFromWeb (Microsoft.Online.SharePoint.PowerShell) | Microsoft Docs

Along with referencing this (but most of it goes over my head) and some other blogs that seem out of date:

The Ultimate Guide to SharePoint Site Designs and Site Scripts (laurakokkarinen.com)

 

This is what I am putting into the SharePoint Online Management Shell:

 

PS C:\windows\System32> $extracted = Get-SPOSiteScriptFromWeb `
>> -WebUrl https://MYTENANT.sharepoint.com/sites/MYSITE `
>> -IncludeBranding `
>> -IncludeTheme `
>> -IncludeRegionalSettings `
>> -IncludeSiteExternalSharingCapability `
>> -IncludeLinksToExportedItems `
>> -IncludedLists ("/ProjectDocs", "/Drawings", "/Contract")
PS C:\windows\System32> Add-SPOSiteScript `
>> -Title "20220520_ProjectTemplate" `
>> -Content $extracted `
>> -Description "Project template site for new project sites."

 

Which returns the error:

 

Add-SPOSiteScript : Action 8 (createSiteColumnXml) is invalid. Parameter schemaXml has an invalid value.
At line:1 char:1
+ Add-SPOSiteScript `
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-SPOSiteScript], ServerException
    + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.AddSP
   OSiteScript

 

 I think this is the section it is picking up:

 

{
      "verb": "createSiteColumnXml",
      "schemaXml": null,
      "pushChanges": true
    },

 

I can output the JSON and edit it, but I don't know how to upload it to SharePoint and assign it an ID so I can carry on. Therefore, I'm a bit stuck.

Could someone help me out, please?

Edit:
Ok, I worked out how to fix and reference the JSON using:

$site_script = Get-Content -Path 'C:\path\file.json' -Raw

And then:

Add-SPOSiteScript `
>> >> -Title "20220520_Test_ProjectTemplate" `
>> >> -Content $site_script  `
>> >> -Description "This is a copy of the project template site, done as a test."

But now I have this error:

At line:3 char:1
+ >> -Content $site_script  `
+ ~~~~~~~~~~~
The output stream for this command is already redirected.
At line:4 char:1
+ >> -Description "This is a copy of the project template site, done as ...
+ ~~~~~~~~~~~~~~~
The output stream for this command is already redirected.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : StreamAlreadyRedirected

So I'm still stuck.

0 Replies