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...

  • Modify it as $site_script = Get-Content -Path "./siteTemplate1.json" -Raw and try Mar 13, 2019 at 8:38
  • Oh boy... shame on me to overlook this.
    – Emiel
    Mar 13, 2019 at 8:50

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.