provide teamsite template trough sitescript: cannot convert Object[] to string
-
06-02-2021 - |
Вопрос
I made a (simple) sitescripttemplate in JSON which I would like to make available for all the users who can create a site.
The inconvenience lies in the fact I only got it working which I write the whole jsoncode in the same PS1 file.
Rather I would prefer to load a file from a directory and work with that content. As you see in my code below
$site_script = Get-Content -Path "./siteTemplate1.json"
$SiteScript = Add-SPOSiteScript -Title "SiteTemplate1" -Content $site_script -Description "SiteTemplate1"
Add-SPOSiteDesign -Title "SiteTemplate1" -WebTemplate "64" -SiteScripts $SiteScript.Id -Description "SiteTemplate1"
error I get
Add-SPOSiteScript : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Content'. Specified method is not supported.
At line:1 char:78
+ ... ipt -Title "SiteTemplate_JoinHubSite" -Content $site_script -Descr ...
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-SPOSiteScript], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Online.SharePoint.PowerShell.AddSPOSiteScript
Thank you Hero to look in to this...
Решение
You need to also pass -Raw
parameter to the get content for Site Script.
So, modify your code as:
$site_script = Get-Content -Path "./siteTemplate1.json" -Raw
When you use the Raw parameter, it returns the value as one string which can then be passed to the Add-SPOSiteScript
command.
Не связан с sharepoint.stackexchange