Home » PowerShell » The new nslookup: Resolve-DnsName

The new nslookup: Resolve-DnsName

Nslookup is a command-line tool for dns name resolution. Resolve-DnsName is the modern version of nslookup. In this blog post I am going to show how to use Resolve-DnsName to query DNS Host Names and much more.

Standard Query

To do a Standard Query simply run the command and specify the host name. Format-Table is not necessary, but helpful.

Resolve-DnsName | Format-Table -AutoSize


Query without Host File

Remember: Your host will first query the host file and the DNS Client Cache. If and only if the host file and the cache returns no result, the DNS Server is contacted. To avoid this, run Resolve-DnsName with the -NoHostFile Parameter.

Resolve-DnsName -NoHostsFile

Query in Cache-Only Mode

To demontrate this, I will clear the Dns Client Cache and then try to query This must lead to an error. Bingo!

Resolve-DnsName -CacheOnly


Specify a DNS-Server

Resolve-DnsName without any parameter will contact your primary DNS-Server, which is configured in the settings of your network card. The parameter -Server allows you to specify other DNS-Servers.

Resolve-DnsName -Server | Format-List


Query for Records

Use the Type Parameter to query for specific records.

MX Records (Mail-Server)

Resolve-DnsName -Type MX


AAAA Records (IPv6 only)

Resolve-DnsName -Type AAAA | Format-List


Wait a minute. Did you notice it? No? Then look at the facebook’s IPv6 Address again. 🙄 They have left nothing to chance.


To use only Link Local Multicast Name Resoultion use the LlmnrOnly Parameter. LLMNR will only work with computers which share the same local link.

Dc01 and my computer share the same link. It works.

Resolve-DnsName dc01 -LlmnrOnly | Format-Table -AutoSize

Unbenannt.PNG is not on the same link. Which leads to an error.


Triple Name Resolution

"","","" | Resolve-DnsName -Type A | Format-Table -AutoSize


Another option is to use nslookup with Foreach-Object.

"","","" | ForEach-Object {nslookup $_}


Run Resolve-DnsName by using a file with Host Names

Use Get-Content to retrieve all the Names from your file. Here is my text file …


And this is the command for A Records (IPv4 Addresses) …


Or all NS Records …


Resolving DNS Names by using the TCP Connection Table

Sometimes I try strange things. Going crazy. 😀 Ok, let me explain the following more closer. Get-NetTCPConnection gives me all current Connections by IP-Address. Right? Ok. So, I tried to call all those connections and then decided to catch one of them and run Resolve-DnsName against it 😉


This gives me the connection to and the local Port 12518. Well, that’s enough to proceed.


Resolve-DnsName (Get-NetTCPConnection -State Established -LocalPort 12518).RemoteAddress -Type PTR | Select-Object NameHost


Oh, it’s Microsoft 😉


Related Links

For checking network and domain connectivity see my articles The modern version of ping: Test-Connection and Checking connectivity to Active Directory: Test-ComputerSecureChannel.


  1. […] checking name resoultion and network connectivity see also: The new nslookup: Resolve-DnsName and The modern version of ping: […]


  2. […] The new nslookup: Resolve-DnsName […]


  3. Rung says:

    Very good detailed article about Resolve-DNSName command. i was looking the way to export the results, that you did not mentioned. But i found my answer here:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s



My name is Patrick Grünauer (pewa2303). I am from Austria. On sid-500 I write about Windows, Cisco and IT-Security in English and German. Have fun while reading!

Patrick Gruenauer
Follow SID-500 on