Invoke-SSPSiteDesign.ps1

<#
    .Synopsis
    Applies a SOP Site Design using PnP to the site/tennant.
    .Description
    This CmdLet applies an existing site design to the site/tennant.
    .Parameter Title
    This parameter contains the title of the Site Design. Site designs are referenced by their title.
    .Parameter Url
    This parameter contains the URL of the site. The default is for the current connection.
    returned by "Get-PnPConnection".
    .Parameter Connection
    This parameter provides the context for the call. The default is the current connection
    returned by "Get-PnPConnection".
#>


function Invoke-SSPSiteDesign {
    param(
        $title,
        $connection = (Get-PnPConnection),
        $tenantConnection = $connection,
        $url
    )
    $siteDesigns = Get-SSPSiteDesign -Title $title -Connection $tenantConnection
    if ($siteDesigns) {
        Write-Host "Applying Design $title as $($siteDesigns[0].Id) $url"
        if ($url) {
            $ignore = Invoke-PnPSiteDesign -Identity $siteDesigns[0].Id -WebUrl $url -Connection $connection
        } else {
            $ignore = Invoke-PnPSiteDesign -Identity $siteDesigns[0].Id -Connection $connection
        }
    } else {
        Write-Host "No design found for $title"
    }
}