Test-DNSRecord.ps1

something exciting

A simple wrapper for the function Resolve-DNSName to perform DNS queries against specific DNS Servers. This in no way replaces Resolve-DNSName but provides some simple enhanced queries that do not require you to remember the names or IP Addresses of the Name Servers that you wish to query. This tool does not include all of the functionality of Resolve-DNSName but will speed up everyday DNS queries and diagnostics.

The parameters enable you to select from a list of Pubic DNS servers to test DNS resolution for a domain. The DNSProvider switch parameter can also be used to select you internal DNS servers and to test against the domains own Name Servers.

The DNSProvider Switch utilises external servers and queries to populate the switch with the relevant internal/external/zone servers to perform the query. Further information can be found in the parameter section.

The internalDNSservers option for the DNSProviders switch performs an AD query to determine the hostname of the Domain Controllers, performs a DNS query against each Domain Controller and displays the results.

The list of popular Public DNS Servers was taken from the article - https://www.lifewire.com/free-and-public-dns-servers-2626062 which also provides some useful information regarding DNS and why you might select different public dns servers for your name resolution.


Table of contents generated with markdown-toc


Examples


EXAMPLE 1
Test-DNSRecord

cmdlet Test-DNSRecord at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
recordName[0]: !?
Please enter DNS record name to be tested. Expected format is either a fully qualified domain name (FQDN) or an IP address (IPv4 or IPv6) e.g. example.com or
151.101.0.81)
recordName[0]: example.com
recordName[1]:

 Name                Type   TTL   Section    IPAddress
 ----                     ----    ---    -------    ---------
 example.com    A      20738 Answer     93.184.216.34
 example.com    A      9744  Answer     93.184.216.34

This example shows Test-DNSRecord without any options. As recordname is a mandatory field, you are prompted to enter a FQDN or an IP.

Back to Top


EXAMPLE 2
Test-DNSRecord -recordName example.com -Type A -DNSProvider GooglePrimary

Name           Type   TTL   Section    IPAddress
----                ----   ---   -------    ---------
example.com    A      20182 Answer     93.184.216.34

This example shows an 'A' record query against Google's Primary Public DNS server.

Back to Top


EXAMPLE 3
Test-DNSRecord -recordName bbc.co.uk -Type CNAME -DNSProvider AllPublic

Name         Type TTL   Section    PrimaryServer       NameAdministrator           SerialNumber
----              ---- ---   -------    -------------       -----------------           ------------
bbc.co.uk    SOA  899   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  899   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  900   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  900   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  900   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  900   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  900   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  898   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  900   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  900   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  900   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  900   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  900   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800
bbc.co.uk    SOA  900   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800

This example shows the results from a CNAME lookup queried against the complete list of Public DNS Servers defined in the DNSProviders parameter.

Back to Top


EXAMPLE 4
Test-DNSRecord -recordName bbc.co.uk -Type CNAME -DNSProvider GooglePrimary -Verbose
VERBOSE: bbc.co.uk
VERBOSE: Checking Google Primary...

Name         Type TTL   Section    PrimaryServer       NameAdministrator           SerialNumber
----              ---- ---   -------    -------------       -----------------           ------------
bbc.co.uk    SOA  899   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800

This example displays the output with the verbose option enabled. The function performs the search and details which DNS Provider is being queried.

Back to Top


EXAMPLE 5
Test-DNSRecord -recordName bbc.co.uk -Type CNAME -DNSProvider InternalDNSserver -Verbose

VERBOSE: bbc.co.uk
VERBOSE: Checking DANTOOINE.domain.leigh-services.com...

Name         Type TTL   Section    PrimaryServer       NameAdministrator           SerialNumber
----              ---- ---   -------    -------------       -----------------           ------------
bbc.co.uk    SOA  899   Authority  ns.bbc.co.uk        hostmaster.bbc.co.uk        2021011800

This example displays the output with the verbose option enabled. The function performs the search and details which DNS Provider is being queried. The InternalDNSserver DNS Provider, performs an AD query and uses the internal AD Servers for DNS resolution.

Back to Top


OutPut

System.String. The output returned from Test-DNSRecord is a string

Back to Top


Script

Details about the script/function/tool/snippet file.

Back to Top


Download

Some information about why this button exists and how you can download the complete repository.

Back to Top


gist-it

I have used gist-it to display the files from my GitHub repository and embed it into the web page. This is very similar to GitHub Gists

Gist-it uses google-code-prettify for Syntax highlighting.

The view raw link at the bottom right of the script will take you to a raw text version of the script which you can copy and paste.

Back to Top


Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes.

Issue

Back to Top


Back to Top