Nslookup is a command-line tool for dns name resolution. Resolve-DnsName is the modern version of nslookup. In this blog post i will show how to use Resolve-DnsName to query DNS Host Names and much more.
To do a Standard Query simply run the command and specify the host name. Format-Table is not necessary, but helpful.
Resolve-DnsName sid-500.com | 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 sid-500.com -NoHostsFile
Query in Cache-Only Mode
To demontrate this, i clear the Dns Client Cache and then i try to query sid-500.com. This must lead to an error. Bingo!
Clear-DnsClientCache Resolve-DnsName sid-500.com -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 sid-500.com -Server 220.127.116.11 | Format-List
Query for Records
Use the Type Parameter to query for specific records.
MX Records (Mail-Server)
Resolve-DnsName cnn.com -Type MX
AAAA Records (IPv6 only)
Resolve-DnsName facebook.com -Type AAAA | Format-List
Wait a minute. Did you notice it? No? Read the IPv6 Address of facebook 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
Sid-500.com is not on the same link. Which leads to an error.
For checking network and domain connectivity see my articles The modern version of ping: Test-Connection and Checking connectivity to Active Directory: Test-ComputerSecureChannel.