While writing a PowerShell script to fix some DNS records, I came across some very strange behavior. I was calling Get-DnsServerResourceRecord
and it was returning duplicate results for every record. One result was correct, and the other one looked like it was the fully qualified domain name. The results made no sense to me, and I couldn’t figure out how now to return these extraneous records.
Bug Report
Turns out this is a bug in the Get-DnsServerResourceRecord cmdlet. This behavior happens when you have a sub-domain that matches the zone’s name (example.com.example.com
).
At least it made me feel less crazy to know a few other people had the same problem.
Workaround
The bug report also mentioned that the WMI calls were not affected. This led me to write a drop-in replacement for Get-DnsServerResourceRecord
, and package it in a script module so that I could easily use it in my own scripts and distribute it. During the course of researching I found another bug related to mult-line/multi-string TXT records, and decided to fix that behavior in my function as well.
The function takes the same parameters and returns output that is nearly the same as the original cmdlet.
The DnsCmdletFixes module is available here on GitHub .
Post any questions/concerns/feedback here.