question

TechUser2020-6505 avatar image
0 Votes"
TechUser2020-6505 asked Evgenij-Smirnov answered

Resolve-DNSName errors for single label names

Hi,
I'm writing a DNS test script to validate DNS functionality post-migration from one DNS platform to another. I'm hitting a couple of issues with the script:

  1. Resolve-DnsNames fails with single-label names, e.g. "Resolve-DnsName server1 -DnsOnly" returns Dns name doesn't exist. Resolve-DnsName with the FQDN works as expected. Nslookup works fine with the single-label name. Is there a way to get Resolve-DnsName working with only single label names?

I've tried using nslookup instead, however it throws errors for non-authoritative answers and I've struggled to catch the errors (they don't seem to caugh with a try catch block).

Advice appreciated.

Thanks




windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

StoyanChalakov avatar image
0 Votes"
StoyanChalakov answered

Hi,

I don't think Resolve-DNSName works with Single Label Domain Names. It does resolve NetBIOS names if you use the proper switch, but not SLDNs.

What I found though is this, which might help you work your way around Resolve-DNSNAme by using nslookup or one of the other methods and also catch errors in your script. There are also some nice examples, which might get you started:

Finding Non-Resolveable IP Addresses
https://tommymaynard.com/tag/resolve-dnsname/

Please let me know if it was really helpfull, thanks in advance!


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Regards,
Stoyan





5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

Try using this instead:

 [System.Net.Dns]::GetHostAddresses("yourhosthere")
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hello @TechUser2020-6505

This can't be achieved with Resolve-DnsName as it needs to have the FQDN to query the right domain and avoid conflicts. Examples: https://docs.microsoft.com/en-us/powershell/module/dnsclient/resolve-dnsname?view=windowsserver2019-ps

Hope this helps with your query,


--If the reply is helpful, please Upvote and Accept as answer--

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Evgenij-Smirnov avatar image
0 Votes"
Evgenij-Smirnov answered

Resolve-DNSName with -DNSOnly switch will only query the DNS server for the exact string you're entering. Short of having a GlobalNames zone, there's no way DNS can answer that because it needs a way to determine the zone where to look up in the first place.

nslookup with default settings will use your suffix search list. If you set the nslookup options nosearch and nodefname you will get the same behaviour.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.