We can retrieve a sitescript using m365 spo sitescript get --id <some-guid>.
The result is a JSON string stringified in a JSON string. There are a few downsides to this:
- It's bad for readability.
- You need to do more work to get at the real sitescript
- (maybe a bug) You'll often get escaped newline characters thrown in.
This is how the output looks for me:
{
"Content": "{\r\\\n \"$schema\": \"https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json\",\r\\\n \"actions\": \r\\\n [ ]\r\\\n}",
"Description": "some description",
"Id": "<some-guid>",
"IsSiteScriptPackage": false,
"Title": "some title",
"Version": 1
}
💡 Idea
Let's add an extra flag-option that will make the command return ONLY the actual site-script JSON instead:
| Option |
Description |
-c, --content |
When used, the command will only return the content of the site script. |
Examples
Returns the site script contents:
m365 spo sitescript get --id 2c1ba4c4-cd9b-4417-832f-92a34bc34b2a --content
Response
Normal response:
{
"Content": "{\"$schema\":\"https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json\",\"actions\":[{\"verb\":\"activateSPFeature\",\"name\":\"SiteNotebook feature\",\"title\":\"SiteNotebook feature\",\"featureId\":\"f151bb39-7c3b-414f-bb36-6bf18872052f\",\"scope\":\"web\"}],\"bindata\":{},\"version\":1}",
"ContentByteArray": null,
"Description": "Contoso site script",
"Id": "43d4ffa0-c7ee-4a97-91d7-db27e5b62de5",
"IsSiteScriptPackage": false,
"Title": "Contoso",
"Version": 1
}
Response with --content flag
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json",
"actions": [ {
"verb":"activateSPFeature",
"name": "SiteNotebook feature",
"title": "SiteNotebook feature",
"featureId": "f151bb39-7c3b-414f-bb36-6bf18872052f",
"scope": "web"}
],
"bindata":{},
"version":1
}
We can retrieve a sitescript using
m365 spo sitescript get --id <some-guid>.The result is a JSON string stringified in a JSON string. There are a few downsides to this:
This is how the output looks for me:
{ "Content": "{\r\\\n \"$schema\": \"https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json\",\r\\\n \"actions\": \r\\\n [ ]\r\\\n}", "Description": "some description", "Id": "<some-guid>", "IsSiteScriptPackage": false, "Title": "some title", "Version": 1 }💡 Idea
Let's add an extra flag-option that will make the command return ONLY the actual site-script JSON instead:
-c, --contentExamples
Returns the site script contents:
Response
Normal response:
{ "Content": "{\"$schema\":\"https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json\",\"actions\":[{\"verb\":\"activateSPFeature\",\"name\":\"SiteNotebook feature\",\"title\":\"SiteNotebook feature\",\"featureId\":\"f151bb39-7c3b-414f-bb36-6bf18872052f\",\"scope\":\"web\"}],\"bindata\":{},\"version\":1}", "ContentByteArray": null, "Description": "Contoso site script", "Id": "43d4ffa0-c7ee-4a97-91d7-db27e5b62de5", "IsSiteScriptPackage": false, "Title": "Contoso", "Version": 1 }Response with
--contentflag{ "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json", "actions": [ { "verb":"activateSPFeature", "name": "SiteNotebook feature", "title": "SiteNotebook feature", "featureId": "f151bb39-7c3b-414f-bb36-6bf18872052f", "scope": "web"} ], "bindata":{}, "version":1 }