public/New-PSUEndpointModule.ps1

function New-PSUEndpointModule {
    <#
    .SYNOPSIS
    Creates a PowerShell Universal endpoint module from the Plaster template.
 
    .DESCRIPTION
    Scaffolds a module with a sample endpoint command and .universal endpoint registration.
 
    .PARAMETER DestinationPath
    The path where the new module should be created.
 
    .PARAMETER ModuleName
    The full module name.
 
    .PARAMETER EndpointName
    The name used for the sample endpoint command and URL.
 
    .PARAMETER Description
    A brief description for the module.
 
    .PARAMETER Author
    The author name for the module.
 
    .PARAMETER Version
    The version number for the module. Default is '1.0.0'.
    #>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory)]
        [string]
        $DestinationPath,

        [Parameter()]
        [string]
        $ModuleName,

        [Parameter()]
        [string]
        $EndpointName,

        [Parameter()]
        [string]
        $Description,

        [Parameter()]
        [string]
        $Author,

        [Parameter()]
        [string]
        $Version
    )

    $templateParameters = @{}
    foreach ($name in 'ModuleName', 'EndpointName', 'Description', 'Author', 'Version') {
        if ($PSBoundParameters.ContainsKey($name)) {
            $templateParameters[$name] = $PSBoundParameters[$name]
        }
    }

    if ($PSCmdlet.ShouldProcess($DestinationPath, 'Create new PSU Endpoint Module')) {
        Invoke-PSUModuleTemplate -TemplateName 'PowerShellUniversalEndpoint' -DestinationPath $DestinationPath -TemplateParameters $templateParameters
    }
}