Public/Spamfilter/Get-SpamfilterDomains.ps1

function Get-SpamfilterDomains {
    process {
        try {
            $Credential = Get-SpamFilterCredential
        }
        catch {
            throw "Failed to retreive Spamfilter credential: $_"
        }

        try {
            $Domains = Invoke-WebRequest -Credential $Credential -Uri "$($SpamfilterAPIBaseURL)/domainslist/get/" | ConvertFrom-Json
        }
        catch {
            throw "Failed to retreive domains from Spamfilter: $_"
        }
        $Domains
    }
}