Public/Get-HibpBreachedAccount.ps1

function Get-HibpBreachedAccount {
    <#
        .SYNOPSIS
            Gets all breaches for a specific account.

        .DESCRIPTION
            Retrieves a list of all breaches in the system for a given account (email address or username).

        .PARAMETER Account
            The account to search for (e.g., 'test@example.com'). This parameter is required.

        .PARAMETER Domain
            Filters the results to only breaches on a specific domain.

        .PARAMETER IncludeFullBreach
            If specified, returns the full breach model instead of just the name.

        .PARAMETER IncludeUnverified
            If specified, results will include unverified breaches.

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

        .EXAMPLE
            Get-HibpBreachedAccount -Account 'test@example.com'

            Returns all breaches for the account 'test@example.com'.

        .EXAMPLE
            Get-HibpBreachedAccount -Account 'test@example.com' -Domain 'adobe.com' -IncludeFullBreach

            Returns the full breach details for any breaches for 'test@example.com' that occurred on 'adobe.com'.

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


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'The email address to search for.', ValueFromPipeline)]
        [string]$Account,

        [string]$Domain,

        [Switch]$IncludeFullBreach,

        [Switch]$IncludeUnverified,

        [string]$ApiKey
    )

    begin {
        $queryParameter = @{}
        if ($PSBoundParameters.ContainsKey('Domain')) { $queryParameter.domain = $Domain }
        if ($IncludeFullBreach.IsPresent) { $queryParameter.truncateResponse = 'false' }
        if ($IncludeUnverified.IsPresent) { $queryParameter.includeUnverified = 'true' }
    }

    process {
        $endpoint = 'breachedaccount/{0}' -f ([System.Web.HttpUtility]::UrlEncode($Account))

        $invokeParams = @{
            Endpoint       = $endpoint
            QueryParameter = $queryParameter
        }

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

        Invoke-HibpRequest @invokeParams
    }
}