For several decades, I’ve used the NSLookup.exe command in DOS and Windows as a way of doing DNS troubleshooting. At one time, I needed it to verify basic domain lookup configuration, but Windows DNS makes it pretty simple to set domains up correctly. More recently, with products such as Lync, there is a need to have other DNS records validated, particularly SRV records that enable client auto-login etc.
NSLookup is not bad – in a former life I actually read bits of the code. It’s a tool I know how to use, and like I tell my PowerShell class, if it isn't broken, don’t fix it. Fair enough, I suppose, but It’s not really very PowerShell friendly.
As part of preparing my next Pluralsight Course, managing DNS with PowerShell, I’ve been playing with some of the new DNS Client cmdlets that come, in specific, for Server 2012 R2. One useful cmdlet is Resolve-DNSName.
Resolve-DNSName does pretty much exactly what NSLookup did, direct from the command line, plus a bit more. The cmdlet, unlike NSLookup, is able to make use of LLMNR, NetBIOS (or not) and can turnoff recursion in answering a query.
Here is some sample output:
PS C:> Resolve-DnsName -type all reskit.org
Name Type TTL Section IPAddress
---- ---- --- ------- ---------
reskit.org A 600 Answer 10.0.0.10
Name : reskit.org
QueryType : NS
TTL : 3600
Section : Answer
NameHost : dc1.reskit.org
Name : reskit.org
QueryType : SOA
TTL : 3600
Section : Answer
NameAdministrator : hostmaster.reskit.org
SerialNumber : 26
TimeToZoneRefresh : 900
TimeToZoneFailureRetry : 600
TimeToExpiration : 86400
DefaultTTL : 3600
dc1.reskit.org A 3600 Additional 10.0.0.10
[Srv1]: PS C:> Resolve-DnsName -Name srv2.reskit.org
Name Type TTL Section IPAddress
---- ---- --- ------- ---------
srv2.reskit.org A 1200 Answer 10.0.0.31
There are also switches for turning on or not DNSSec and EDNS, and can request any/all, or specific RR types. Long live Resolve-DNSName!