Create a site design for team site w/o O365 group
-
05-02-2021 - |
Pregunta
I've been testing how to create site scripts and site designs for our SharePoint online sites that use O365 groups, such as Teams sites and Communication sites. The scripts work just fine and I'm able to create the designs and select them from the drop down. But I'd like to be able to do the same thing for a team site that will not be using O365 groups. The piece where I'm having issues with is what web template to select. I know for a team site with O365 groups the value is "64", for a communication site is "68", but what should I use for the non-O365 groups team site?
Below is an example of the PS script I'm using:
$adminSiteUrl = "https:url.sharepoint.com"
$siteScriptFile = $PSScriptRoot + "\customTeamSiteScript.json"
$webTemplate = "64"
$siteScriptTitle = "Team Site Script"
$siteDesignTitle = "Team Site Design"
$siteDesignDescription = "This is a test design for Team site creation."
$previewImageUrl = "https://url.sharepoint.com/SiteAssets/logo.png"
$cred = Get-Credential
Connect-SPOService $adminSiteUrl -Credential $cred
$siteScript = (Get-Content $siteScriptFile -Raw | Add-SPOSiteScript -Title $siteScriptTitle) | Select -First 1 Id
Add-SPOSiteDesign -SiteScripts $siteScript.Id -Title $siteDesignTitle -WebTemplate $webTemplate -Description $siteDesignDescription -PreviewImageUrl $previewImageUrl
Any help is appreciated.
Thank you
Solución
The webtemplateId for Modern team site without O365 group is 1
.
So, you can set the value as below:
$adminSiteUrl = "https:url.sharepoint.com"
$siteScriptFile = $PSScriptRoot + "\customTeamSiteScript.json"
$webTemplate = "1"
Reference - Get a list of web templates and IDs in a SharePoint site
While the reference link is quite old, one way to find out the value is to go to any document library/list and go to its settings page. They are still in classic mode and hence they contain the _spPageContextInfo
object.
So, by simply typing _spPageContextInfo.webTemplate
in the console, we get the value of the webTemplate. Unfortunately, this templateId
value is not exposed programmatically, so using this workaround we can get the value. If you do the same in communication site or team site with O365 group, we get 68
and 64
respectively.