Add-PorteoSiteDesigns.ps1

#
# This file adds specific site scripts that are in the SiteScripts directory to the tennant site.
# It then defines a set of Site Designs that will run the scripts. See below.
#
# Make sure you have a default connection to the tennant.
#
# Connect-PnPOnline -Url https://tennant.sharepoint.com -Credential (Get-Credential)
#
# This script need only be run once, but is idempotent, or will update in place.
#

function defineSiteScript {
    param(
        $title,
        $connection,
        [Switch] $force
    )
    $content = (Get-Content "$PSScriptRoot/SiteScripts/$title.json" -Raw)
    return Add-SSPSiteScript -Title $title  -Description "The $title" -Content $content -Force:$force -Connection $connection
}

<#

    .Synopsis
    Add-PorteoSiteDesigns -Type TeamSite -Connection $connection -Force
    .Description
    This function adds the default site designs contained in this module to a site so that they may be used
    to provision a target site on the tenant specified by the `-Connection` argument.
    .Example
    $creds = Get-Credential
    $conn = Connect-PnPOnline -Url "https://site-admin.sharepoint.com" -Credentials $creds
    Add-PorteoSiteDesigns -Type TeamSite -Connection $conn -Force
#>


function Add-PorteoSiteDesigns
{
    param (
        $type,
        $connection = (Get-PnPConnection),
        [Switch] $force
    )
    Write-Host "Add-PorteoSiteDesigns"
    Get-ChildItem -Path "$PSScriptRoot/SiteScripts" | Where-Object {
        Write-Host "DefineSiteScript $($_.BaseName)"
        defineSiteScript -Title $_.BaseName -Connection $connection -Force:$force
    }

    $scriptNames = ("DefaultBranding", "DefaultRegionalSettings", "DefaultSiteExternalSharingCapability", "DefaultTheme")
    Add-SSPSiteDesign -Title "DefaultDesign" -Type $type -SiteScriptIds $scriptNames -Connection $connection -Force:$force

    Add-SSPSiteDesign -Title "AddJournal" -Type $type -SiteScriptIds ("Journal") -Connection $connection -Force:$force
    Add-SSPSiteDesign -Title "AddLinks" -Type $type -SiteScriptIds ("Links") -Connection $connection -Force:$force
    Add-SSPSiteDesign -Title "AddRequests" -Type $type -SiteScriptIds ("Requests") -Connection $connection -Force:$force
    Add-SSPSiteDesign -Title "AddSiteLists" -Type $type -SiteScriptIds ("SiteCollectionList", "SubsitesList") -Connection $connection -Force:$force
    Add-SSPSiteDesign -Title "UseDarkBlueTheme" -Type $type -SiteScriptIds ("DarkBlueTheme") -Connection $connection -Force:$force
    Add-SSPSiteDesign -Title "SetLogo" -Type $type -SiteScriptIds ("SetLogo") -Connection $connection -Force:$force
}