Private/Storage/Get-PukAllRecords.ps1

function Get-PukAllRecords {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = 'Bulk-fetch-all private helper; "AllRecords" is the clearest name for this specific verb+noun family (see Get-PukRecord for the single-record counterpart) and is not part of the public cmdlet surface.')]
    [CmdletBinding()]
    [OutputType([System.Object[]])]
    param(
        [Parameter(Mandatory)]
        [psobject]$Config,

        [Parameter(Mandatory)]
        [System.Security.Cryptography.X509Certificates.X509Certificate2]$Certificate,

        [string]$Server
    )

    $records = switch ($Config.hosting.model) {
        'FlatFile' {
            (Get-PukFlatFileStore -Path $Config.hosting.flatFile.path -Certificate $Certificate).records
        }
        'ActiveDirectory' {
            $params = @{ AttributeName = $Config.hosting.activeDirectory.attributeName; Certificate = $Certificate }
            $effectiveServer = if ($Server) { $Server } else { $Config.hosting.activeDirectory.server }
            if ($effectiveServer) { $params.Server = $effectiveServer }
            if ($Config.hosting.activeDirectory.searchBase) { $params.SearchBase = $Config.hosting.activeDirectory.searchBase }
            Get-PukAdAllRecords @params
        }
        default { throw "Unsupported hosting model '$($Config.hosting.model)'." }
    }

    return @($records | ForEach-Object {
            [PSCustomObject]@{
                PSTypeName        = 'PWSHPUKMGT.Record'
                DistinguishedName = $_.DistinguishedName
                SerialNumber      = $_.SerialNumber
                Puk               = $_.Puk
            }
        })
}