public/Show-OSDeployLicense.ps1

function Show-OSDeployLicense {
    <#
    .SYNOPSIS
        Shows the selected Recast Software license
 
    .DESCRIPTION
        Searches the standard Recast Software license directory for .license2 files and
        returns the license candidate selected by Get-OSDCoreLicense. The returned object
        includes validation details; selection does not require the candidate to be valid
        or unexpired.
 
        When no license candidate can be selected, writes a warning and displays Community
        License registration, installation, and verification guidance. That path does not
        return an object.
 
    .EXAMPLE
        PS> Show-OSDeployLicense
 
        Returns the selected license object, or displays registration guidance when no
        license candidate is found.
 
    .EXAMPLE
        PS> $License = Show-OSDeployLicense
 
        Stores the selected license object in $License. $License remains empty when no
        candidate is found.
 
    .INPUTS
        None. This function does not accept pipeline input.
 
    .OUTPUTS
        System.Management.Automation.PSCustomObject. Returns the selected parsed license
        candidate when one is found. Returns no object when none is found.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Version: 1.0.0
        Date: 2026-08-28
 
        License discovery may create the standard license directory when it does not exist.
 
    .LINK
        https://www.osdeploy.com/guide/registration
    #>

    [CmdletBinding()]
    [OutputType([System.Management.Automation.PSCustomObject])]
    param ()

    Write-HostOSDeployBanner

    # Return only a valid detected license; otherwise show the registration guidance.
    $License = Get-OSDCoreLicense
    if ($License -and $License.IsValid) {
        return $License
    }

    if ($License -and -not $License.IsValid) {
        Write-Warning "[$(Get-Date -Format s)] Detected license candidate is not valid."
    }

    Show-OSDCoreLicenseHelp
}