Public/Get-HibpLatestBreach.ps1

function Get-HibpLatestBreach {
    <#
        .SYNOPSIS
            Gets the most recent breach added to the system.

        .DESCRIPTION
            Retrieves the details of the single most recent breach added to the Have I Been Pwned system.

        .PARAMETER ApiKey
            Your HIBP API key. Can be used instead of saving the key with Save-HibpCredential.

        .EXAMPLE
            Get-HibpLatestBreach

            Returns the latest breach in the system.

        .LINK
            https://haveibeenpwned.com/API/v3#MostRecentBreach
    #>


    [CmdletBinding()]
    Param(
        [string]$ApiKey
    )

    $invokeParams = @{
        Endpoint = 'latestbreach'
    }

    if ($PSBoundParameters.ContainsKey('ApiKey')) {
        $invokeParams.ApiKey = $ApiKey
    }

    Invoke-HibpRequest @invokeParams
}