Add-SSPSite.ps1

<#
    .Synopsis
    Adds a SSP Site using PnP to the site/tennant.
    .Description
    This CmdLet addes a new site.
    .Parameter Owner
    This parameter contains the owner of the Site.
    .Paramter SiteUrl
    This parameter contains the url of the site. It is optional for TeamSite, in which -Connection is required.
    .Parameter Title
    This parameter contains the title of the Site.
    .Parameter SiteName
    This parameter contains the name of the Site.
    .Parameter Type
    This parameter contains the type of site to create.
    The default is 'TeamSite'.
    .Parameter SiteDesignNames
    This parameter contains a list of Site Design names to invoke on the new site.
    .Parameter Lcid
    This paramter holds the language for the new site. Default is "1033" English.
    .Parameter Connection
    This parameter provides the context for the call. The default is the current connection
    returned by "Get-PnPConnection". It is required for -Type TeamSite.
#>


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