10 DNS questions solved with Resolve-DnsName

The Resolve-DnsName cmdlet is a powerful network administration tool command-line tool in PowerShell, used for querying DNS to obtain domain names or IP addresses, mapping or for any other specific DNS Records.

In this post I show you ten frequently used command lines with Resolve-DnsName that will help you better your domain management.

1. How to find A records for a domain?

# Command line:
PS C:\> Resolve-DnsName -Name google.com

# Output:
Name                                           Type   TTL   Section    IPAddress
----                                           ----   ---   -------    ---------
google.com                                     AAAA   156   Answer     2a00:1450:400f:80c::200e
google.com                                     A      252   Answer     216.58.211.142

2. How to check the NS records of a domain?

# Command line:
PS C:\> Resolve-DnsName -Name google.com -Type NS

# Output:
Name                           Type   TTL   Section    NameHost
----                           ----   ---   -------    --------
google.com                     NS     6883  Answer     ns3.google.com
google.com                     NS     6883  Answer     ns4.google.com
google.com                     NS     6883  Answer     ns1.google.com
google.com                     NS     6883  Answer     ns2.google.com

Name       : ns3.google.com
QueryType  : A
TTL        : 5137
Section    : Additional
IP4Address : 216.239.36.10


Name       : ns3.google.com
QueryType  : AAAA
TTL        : 85550
Section    : Additional
IP6Address : 2001:4860:4802:36::a


Name       : ns4.google.com
QueryType  : A
TTL        : 5137
Section    : Additional
IP4Address : 216.239.38.10


Name       : ns4.google.com
QueryType  : AAAA
TTL        : 9817
Section    : Additional
IP6Address : 2001:4860:4802:38::a


Name       : ns1.google.com
QueryType  : A
TTL        : 5137
Section    : Additional
IP4Address : 216.239.32.10


Name       : ns1.google.com
QueryType  : AAAA
TTL        : 7013
Section    : Additional
IP6Address : 2001:4860:4802:32::a


Name       : ns2.google.com
QueryType  : A
TTL        : 5138
Section    : Additional
IP4Address : 216.239.34.10


Name       : ns2.google.com
QueryType  : AAAA
TTL        : 8317
Section    : Additional
IP6Address : 2001:4860:4802:34::a

3. How to query the SOA record of a domain?

This is useful to find the contact person of a domain you don’t administrate. For instance if you need to change or add a record of a domain, contact the Name Administrator to get assistance, in this case the Name Administrator is dns-admin.google.com, this means the contact information is dns-admin@google.com.

# Command line:
PS C:\> Resolve-DnsName -Name google.com -Type SOA

# Output:
Name                        Type TTL   Section    PrimaryServer               NameAdministrator           SerialNumber
----                        ---- ---   -------    -------------               -----------------           ------------
google.com                  SOA  32    Answer     ns1.google.com              dns-admin.google.com        245226112

Name       : ns1.google.com
QueryType  : A
TTL        : 5114
Section    : Additional
IP4Address : 216.239.32.10


Name       : ns1.google.com
QueryType  : AAAA
TTL        : 6990
Section    : Additional
IP6Address : 2001:4860:4802:32::a

4. How to find the MX records, responsible for the mail exchange?

# Command line:
PS C:\> Resolve-DnsName -Name google.com -Type MX

# Output:
Name                                     Type   TTL   Section    NameExchange                              Preference
----                                     ----   ---   -------    ------------                              ----------
google.com                               MX     307   Answer     alt2.aspmx.l.google.com                   30
google.com                               MX     307   Answer     alt3.aspmx.l.google.com                   40
google.com                               MX     307   Answer     alt4.aspmx.l.google.com                   50
google.com                               MX     307   Answer     aspmx.l.google.com                        10
google.com                               MX     307   Answer     alt1.aspmx.l.google.com                   20

5. How to find all of the available DNS records of a domain?

# Command line:
PS C:\> Resolve-DnsName -Name google.com -Type ANY

# Output:
Name                                           Type   TTL   Section    IPAddress
----                                           ----   ---   -------    ---------
google.com                                     A      300   Answer     172.217.21.142

Name      : google.com
QueryType : NS
TTL       : 86400
Section   : Answer
NameHost  : ns1.google.com


Name      : google.com
QueryType : NS
TTL       : 86400
Section   : Answer
NameHost  : ns2.google.com


Name      : google.com
QueryType : NS
TTL       : 86400
Section   : Answer
NameHost  : ns3.google.com


Name      : google.com
QueryType : NS
TTL       : 86400
Section   : Answer
NameHost  : ns4.google.com


Name                   : google.com
QueryType              : SOA
TTL                    : 60
Section                : Answer
NameAdministrator      : dns-admin.google.com
SerialNumber           : 245226112
TimeToZoneRefresh      : 900
TimeToZoneFailureRetry : 900
TimeToExpiration       : 1800
DefaultTTL             : 60


Name         : google.com
QueryType    : MX
TTL          : 600
Section      : Answer
NameExchange : alt2.aspmx.l.google.com
Preference   : 30


Name         : google.com
QueryType    : MX
TTL          : 600
Section      : Answer
NameExchange : alt3.aspmx.l.google.com
Preference   : 40


Name         : google.com
QueryType    : MX
TTL          : 600
Section      : Answer
NameExchange : aspmx.l.google.com
Preference   : 10


Name         : google.com
QueryType    : MX
TTL          : 600
Section      : Answer
NameExchange : alt1.aspmx.l.google.com
Preference   : 20


Name         : google.com
QueryType    : MX
TTL          : 600
Section      : Answer
NameExchange : alt4.aspmx.l.google.com
Preference   : 50


Name      : google.com
QueryType : TXT
TTL       : 3600
Section   : Answer
Strings   : {v=spf1 include:_spf.google.com ~all}


Name      : google.com
QueryType : TXT
TTL       : 3600
Section   : Answer
Strings   : {globalsign-smime-dv=CDYX+XFHUw2wml6/Gb8+59BsH31KzUr6c1l2BPvqKX8=}


Name      : google.com
QueryType : TXT
TTL       : 300
Section   : Answer
Strings   : {facebook-domain-verification=22rm551cu4k0ab0bxsw536tlds4h95}


Name      : google.com
QueryType : TXT
TTL       : 300
Section   : Answer
Strings   : {docusign=05958488-4752-4ef2-95eb-aa7ba8a3bd0e}

google.com                                     AAAA   300   Answer     2a00:1450:400f:809::200e
ns1.google.com                                 A      4647  Additional 216.239.32.10
ns1.google.com                                 AAAA   6523  Additional 2001:4860:4802:32::a
ns2.google.com                                 A      4648  Additional 216.239.34.10
ns2.google.com                                 AAAA   7827  Additional 2001:4860:4802:34::a
ns3.google.com                                 A      4647  Additional 216.239.36.10
ns3.google.com                                 AAAA   85060 Additional 2001:4860:4802:36::a
ns4.google.com                                 A      4647  Additional 216.239.38.10
ns4.google.com                                 AAAA   9327  Additional 2001:4860:4802:38::a
alt2.aspmx.l.google.com                        A      16    Additional 74.125.195.27
alt2.aspmx.l.google.com                        AAAA   76    Additional 2607:f8b0:400e:c09::1b
alt3.aspmx.l.google.com                        A      129   Additional 108.177.104.26
alt1.aspmx.l.google.com                        A      174   Additional 108.177.125.27
alt1.aspmx.l.google.com                        AAAA   76    Additional 2404:6800:4008:c01::1b
alt4.aspmx.l.google.com                        A      86    Additional 74.125.129.27
alt4.aspmx.l.google.com                        AAAA   230   Additional 2607:f8b0:4001:c15::1b

6. How to lookup with using a specific DNS Server?

# Command line:
PS C:\> Resolve-DnsName -Name google.com -Server 1.1.1.1 # Uses Cloudflare's Name Servers

# Output:
Name                                           Type   TTL   Section    IPAddress
----                                           ----   ---   -------    ---------
google.com                                     AAAA   56    Answer     2a00:1450:400f:809::200e
google.com                                     A      152   Answer     172.217.21.142

7. How to check the Reverse DNS lookup?
By using the IP address instead of hostname you perform a reverse lookup, without adding any parameters.

# Command line:
PS C:\> Resolve-DnsName -Name 172.217.22.174

# Output:
Name                           Type   TTL   Section    NameHost
----                           ----   ---   -------    --------
174.22.217.172.in-addr.arpa    PTR    1103  Answer     arn09s11-in-f14.1e100.net
174.22.217.172.in-addr.arpa    PTR    1103  Answer     arn09s11-in-f174.1e100.net

8. How to resolve queries using only the DNS protocol? Port 53

# Command line:
PS C:\> Resolve-DnsName -Name google.com -DnsOnly

9. How to shorten timeouts for a reply?

# Command line:
PS C:\> Resolve-DnsName -Name google.com -QuickTimeout

10. How to skip the hosts file when resolving a query?

This is useful when you are testing websites or network flow when you need to add changes to the hosts file. It allows you to query a hostname without commenting out or remove the changes to query before and after changes. This allows you to query changes with and without hosts file in an easy manner, without the need to comment or remove changes in the hosts file for each lookup during a test period.

  # Command line:
  PS C:\> Resolve-DnsName -Name google.com -NoHostsFile

For More Content See the Latest Posts