SharePoint Site Script throwning error
-
15-01-2021 - |
题
I am planning to use SharePoint Site Scripts to provision modern sites
. But, when I run command on PowerShell to add site script I am running to error.
I am facing the same issue, in other tenant as well. I checked this command with three developer tenants but all run into same issue. I also tried with PnPPowerShell
but result into same problem.
Edit
When running the Get-SPOSiteScript
command on any of those tenants, I am not getting anything but also it is not resulting into error. Following is the screenshot:
解决方案
You are passing the string incorrectly. Enclose it inside @'
and '@
as mentioned below:
$pnpTemplate = @'
{
"$schema": "schema.json",
"actions": [
{
"verb": "createSPList",
"listName": "Customer Tracking",
"templateType": 100,
"subactions": [
{
"verb": "SetDescription",
"description": "List of Customers and Orders"
}
]
}
],
"version": 1
}
'@
After that, you can run the SPO command as:
Add-SPOSiteScript -Title "Create Column RnD" -Content $pnpTemplate
Or the PnP command as :
Add-PnPSiteScript -Title "Create Column RnD" -Content $pnpTemplate