Important: You may need to update your SharePoint Online Management Shell to the version 16.0.7414.1200 or later, in order to use the demonstrated PowerShell commands below.
Topics:
- Understanding site scripts
- Create a site script and a site design
- Manage access to site design
- Create a SharePoint site from a site design
- Apply site design to an existing SharePoint site
1. Understanding site scripts
If
you have been working with PnP to provision content to SharePoint sites, you’ll
notice that site scripts have no similarity to the PnP schema, which is ok,
since PnP is an open source project maintained by the community and not by
Microsoft. Now Microsoft brought his own toy to the site provisioning’s
playground. It supports triggering Flow, but in terms of provisioning it
includes much fewer functions than PnP.
The
site script’s schema is not difficult to understand since it is based on a JSON
structure which works with a list of actions. Each action is specified by a
verb value which must be written correctly
since they are treated as case sensitive values. Below you see a list of
supported actions:
- applyTheme: Applies a custom theme
- setSiteExternalSharingCapability: Manages guest access
- createSPList: Creates a new list
- addNavLink: Adds a navigation link
- triggerFlow: Triggers a Microsoft flow
- setSiteLogo: Sets a logo to a communication site (Not supported in team sites)
- joinHubSite: Joins a hub site
Here
is what a site script schema configured with all the actions above looks like:
Here you find recent information about site scripts’ supported actions.
2. Create a site script and a site design
This
step demonstrates to you how to add the site script above to SharePoint online
and to create a site design which uses that site script.
The
property WebTemplate provides the set up for the following templates:
- 1: Register this site design with the team site template (group-less) - Not working yet - Issue has already been reported
- 64: Register this site design with the team site template (modern site)
- 68: Register this site design with the communicate site template
The
property SiteScript is an array of site scripts which run the entered scripts
in the listed order. Here is what the added site design looks like in
SharePoint:
3. Manage access to site design
Image
this scenario: only site collection administrators can create sites in your
organization. Scoping was added to site designs to handle this business
requirement exactly. You can configure site designs to only appear for specific groups
or people in your tenant.
Site
designs are by default available to everyone in your organization, but there
are two different kinds of scopes you can set up:
- User: Email address – e.g.: jarbas.horst@example.onmicrosoft.com
- Security Group: Group’s display name or principal – e.g.: Administrators or c:0t.c|tenant|5ec63687-daf1-4d36-8689-213cdf2f3767
The
example below shows how to specify the scope by a security group:
The
property Rights can only be set up to View
which restricts the site design’s usage to the defined users/groups.
4. Create a SharePoint site from a site design
You
can start creating your SharePoint sites based on the site design you’ve just
created from the SharePoint UI. Below you'll find the steps needed:
- Navigate to your SharePoint site’s home page (https://example.sharepoint.com/_layouts/15/sharepoint.aspx)
- Click Create site
- Select Team site since we created a site design for team sites
- Choose the design we’ve just created (Project)
- Enter a site name, click Next than Finish
- Click View updated site after the script applied
5. Apply site design to an existing SharePoint site
Running
a site design on an existing SharePoint site processes delta changes. This means
that either changes apply to the site without corrupting existing data or that a
full provision occurs. Of course, the full provision will occur if the provisioned
data hasn't been available in the site before.
This
can only be done programmatically since there is no UI support yet. The
PowerShell script below demonstrates to you how to run the site design on an
existing site.
Summary:
I
see two great advantages to SharePoint administrators in working with site design:
- Direct integration in the SharePoint UI: Anyone can create custom SharePoint sites without the need to run PowerShell scripts, such as PnP.
- Capability of triggering Flow: "Everything" is possible J For instance, you can continue using your PnP templates from Microsoft Flow.
I
can't wait to see what Microsoft has planned for site designs.