Add-SSPSite.ps1

<#
    .Synopsis
    Adds a SOP Site Design using PnP to the site/tennant.
    .Description
    This CmdLet addes a new site design. If no Site Script Ids are defined then it adds
    a bogus one, so that they may be set later.
    .Parameter Title
    This parameter contains the title of the Site, which is displayed.
    .Parameter SiteName
    This parameter contains the name of the Site. The name is supplied in its URL.
    .Parameter Type
    This parameter contains the type of site to create. It is either 'TeamSite' or 'CommunicationSite'.
    The default is 'TeamSite'.
    .Parameter SiteDesigns
    This parameter contains a list of Site Design Titles to invoke on the new site.
    .Parameter Connection
    This parameter provides the context for the call. The default is the current connection
    returned by "Get-PnPConnection".
#>


function Add-SSPSite {
    param(
        [string] $owner,
        [string] $siteUrl,
        [string] $siteName,
        [string] $title,
        $type = "TeamSite",
        [string[]] $siteDesignNames,
        $connection = (Get-PnPConnection)
    )
    if ($type -eq "TeamSite")
    {
        $site = New-PnPSite -Owners ($owner) -Type $type -Title $title -Alias $siteName -Connection $connection
    } else {
        $site = New-PnPSite -Owner $owner -Type $type -Title $title -Alias $siteName -Connection $connection
    }
    if ($siteDesignNames) {
        Write-Host "Invoking Site Designs $SiteDesignNames"
        $ignore = Invoke-SSPSiteDesigns -Type $type -Url $siteUrl -SiteDesigns $siteDesignNames -Connection $connection
    }
    return $site
}