【SharePoint】既存のサイトからサイトスクリプトを取得する

f:id:tecchan365:20191109160915p:plain

既存のサイトからサイトスクリプトを取得する方法です。

事前準備

PnP PowerShellをインストールしてください。

mynote365.hatenadiary.com

SharePointに接続

以下のps1ファイルを作成・実行し、SharePointに接続します。

$siteCollectionUrl = "https://<<tenant>>.sharepoint.com/sites/<<siteCollectionName>>/"
Connect-PnPOnline –Url $siteCollectionUrl –Credentials (Get-Credential)

エラーが表示されなければ、接続完了です。

サイトスクリプトを取得する

以下のps1ファイルを作成・実行します。

# サイトスクリプトの取得
$weburl = "https://contoso.sharepoint.com/sites/test"
Get-SPOSiteScriptFromWeb -WebUrl $weburl -IncludeTheme

正常に実行されると、指定したURLの、指定したパラメータ(-IncludeTheme)のサイトスクリプトがコマンド画面に表示されます。

f:id:tecchan365:20191109154027p:plain

指定できるパラメータと、取得例は以下の通りです。

パラメータ 取得例
-IncludedLists "verb": "createSPList",
"listName": "test",
"templateType": 100,
"subactions": [
{
"verb": "addSPFieldXml",
"schemaXml": ""
},
{
"verb": "addSPFieldXml",
"schemaXml": "選択肢 1選択肢 2選択肢 3"
},
{
"verb": "addSPView",
"name": "すべてのアイテム",
"viewFields": [
"LinkTitle",
"MultiLine",
"MultiChoice"
],
"query": "",
"rowLimit": 30,
"isPaged": true,
"makeDefault": true,
"formatterJSON": ""
}
]
-IncludeBranding "verb": "setSiteBranding",
"navigationLayout": "Megamenu",
"headerLayout": "Compact",
"headerBackground": "Strong",
"showFooter": true
-IncludeTheme "verb": "applyTheme",
"themeJson": {
"version": "2",
"isInverted": false,
"palette": {
"themePrimary": "#ff004e8c",
"themeLighterAlt": "#fff0f6fa",
"themeLighter": "#ffc7dced",
"themeLight": "#ff9abfdd",
"themeTertiary": "#ff4a88ba",
   ...
}
-IncludeRegionalSettings "verb": "setRegionalSettings",
"timeZone": 13,
"locale": 1041,
"sortOrder": 21,
"hourFormat": "24"
-IncludeSiteExternalSharingCapability "verb": "setSiteExternalSharingCapability",
"capability": "Disabled"

サイトスクリプト・サイトデザインの活用方法は、以下を参照ください。

mynote365.hatenadiary.com

以上です。