Private/New-Psd1File.ps1

function New-Psd1File {
    <#
    .SYNOPSIS
        Creates a PowerShell module manifest (.psd1) file.
 
    .DESCRIPTION
        This function generates a module manifest file (.psd1) with essential metadata for a PowerShell module.
        This includes the module name, version, author, description, and other settings.
 
    .PARAMETER name
        Required. The name of the PowerShell module.
 
    .PARAMETER path
        Required. The path where the module manifest file will be created.
 
    .PARAMETER moduleShortDescription
        Required. A concise description of the module's functionality.
 
    .EXAMPLE
        New-Psd1File -name MyModule -path C:\MyProject\Modules -moduleShortDescription "Provides data analysis tools"
        This creates a file named "MyModule.psd1" in the "C:\MyProject\Modules" directory.
 
    .NOTES
        Author: owen.heaume
        Version: 1.0.0 - Initial release
    #>


    [cmdletbinding()]

    param (
        [parameter (mandatory = $true)]
        [string]$name,

        [parameter (mandatory = $true)]
        [string]$path,

        [parameter (mandatory = $true)]
        [string]$moduleShortDescription
    )

    $tags = @('spec')
    $year = (Get-Date).Year

    $params = @{
        path              = (Join-Path $Path "$name.psd1")
        rootModule        = $name
        moduleversion     = '1.0.0'
        author            = (Get-CimInstance -ClassName CIM_ComputerSystem).username | Split-Path -Leaf
        CompanyName       = 'Specsavers'
        Description       = $moduleShortDescription
        Powershellversion = '3.0'
        tags              = $tags
        releaseNotes      = '* 1.0.0 - Initial Release to PowerShell Gallery'
        Copyright         = "(c) $year Specsavers. All rights reserved."
    }

    Write-Host "Creating module manifest (.psd1) $(Join-Path $Path "$name.psd1")" -ForegroundColor DarkCyan

    try {

        if (Test-Path (Join-Path $Path "$name.psd1")) {
            Write-Host "Module manifest already exists" -ForegroundColor DarkYellow
        } else {
            New-ModuleManifest @params
            Write-Host "Module manifest created successfully" -ForegroundColor darkGreen
        }
    } catch {
        Write-Warning "Unable to create the module manifest. $_"
    }
}