something exciting

Some information about the exciting thing

Table of contents generated with markdown-toc


Function Get-PublicDnsRecord {
        Make some DNS query based on Stat DNS.
        Use Invoke-WebRequest on Stat DNS to resolve DNS query.
        Get-PublicDnsRecord -DomaineNAme "" -DnsRecordType A,MX
        Get-PublicDnsRecord -DomaineNAme "" -DnsRecordType A,MX
    .PARAMETER DomainName
        Domain name to query.
    .PARAMETER DnsRecordType
        DNS type to query.
        [Parameter(Mandatory = $true,
            HelpMessage = 'DNS domain name to query.',
            Position = 1)]

        [Parameter(Mandatory = $true,
            HelpMessage = 'DNS record type to query.',
            Position = 2)]
        [ValidateSet('A', 'AAAA', 'CERT', 'CNAME', 'DHCIP', 'DLV', 'DNAME', 'DNSKEY', 'DS', 'HINFO', 'HIP', 'IPSECKEY', 'KX', 'LOC', 'MX', 'NAPTR', 'NS', 'NSEC', 'NSEC3', 'NSEC3PARAM', 'OPT', 'PTR', 'RRSIG', 'SOA', 'SPF', 'SRV', 'SSHFP', 'TA', 'TALINK', 'TLSA', 'TXT')]

    DynamicParam {
        $AttribColl = New-Object -TypeName System.Collections.ObjectModel.Collection[System.Attribute]
        $ParamAttrib = New-Object -TypeName System.Management.Automation.ParameterAttribute
        $ParamAttrib.Mandatory = $false
        $ParamAttrib.ParameterSetName = '__AllParameterSets'
        $ParamAttrib.ValueFromPipeline = $false
        $ParamAttrib.ValueFromPipelineByPropertyName = $false
        $AttribColl.Add((New-Object -TypeName System.Management.Automation.ValidateSetAttribute -ArgumentList ((Invoke-WebRequest -Uri '' | Select-Object -ExpandProperty Content | ConvertFrom-Json | Select-Object -ExpandProperty nodes | Select-Object -ExpandProperty name))))
        $RuntimeParam = New-Object -TypeName System.Management.Automation.RuntimeDefinedParameter -ArgumentList ('Node', [string], $AttribColl)
        $RuntimeParamDic = New-Object -TypeName System.Management.Automation.RuntimeDefinedParameterDictionary
        $RuntimeParamDic.Add('Node', $RuntimeParam)

    Begin {
        $PsBoundParameters.GetEnumerator() | ForEach-Object -Process { New-Variable -Name $_.Key -Value $_.Value -ErrorAction 'SilentlyContinue' }
        if (!$Node) { $Node = Invoke-WebRequest -Uri '' | Select-Object -ExpandProperty Content | ConvertFrom-Json | Select-Object -ExpandProperty nodes | Select-Object -ExpandProperty name | Get-Random }
    Process {
        ForEach ($Record in $DnsRecordType) {
            Try {
                $WebUrl = '{0}/{1}/{2}' -f $Node, $DomainName, $Record

                Write-Verbose -Message "Constructed URL for query is $WebUrl."

                $WebData = Invoke-WebRequest -Uri $WebUrl -ErrorAction Stop | Select-Object -ExpandProperty Content | ConvertFrom-Json | Select-Object -ExpandProperty answer
                $WebData | % {
                    New-Object -TypeName PSObject -Property @{
                        'Name'   = $
                        'Type'   = $_.type
                        'Target' = $_.rdata
                        'Node'   = $Node
            catch {
                Write-Warning -Message $_
                New-Object -TypeName PSObject -Property @{
                    'Name'   = $DomainName
                    'Type'   = $Record
                    'Target' = ($_[0].ErrorDetails.Message -split '"')[-2]
                    'Node'   = $Node
    End {}

Back to Top


Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.

Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.


Back to Top