Author Posts

April 30, 2018 at 2:10 pm

I am working with a company that has a a number of parent and child domains in DNS. The layout is something like this:

parent.com
intra.parent.com
MI.intra.parent.com
IN.intra.parent.com
KY.intra.parent.com
etc...
meet.parent.com
meetHQ.parent.com
etc...
sip.parent.com
etc...
etc...

I am attempting to write a script that will search through all of DNS for A records. When I attempt to list all forward lookup zones, like so:

Get-DnsServerZone -ComputerName dnsServer01 |
    Where-Object {$_.IsReverseLookupZone -eq $false} | 
        Out-GridView

I get only the top level zones (intra.parent.com, meet.parent.com, etc.). I cannot return MI.intra.parent.com, or KY.intra.parent.com. This is leaving me unable to search for the A records in all areas.

As an alternative, I have tried searching for the records using the .Net method, like so:

$pc = "testPC1"
[System.Net.Dns]::GetHostByName($pc)

and this returns the HostName including Zone name, CNAME and IP address(es) as I would expect. But I am unsure how then to translate this into a method of modifying or deleting the record, as even a straight call to that zone is failing for me. For example, running the code above gives me the output of "testPC1.MI.intra.parent.com", however if I run this:

Get-DnsServerResourceRecord -ComputerName $DNSServer -ZoneName "mi.intra.parent.com" -Node "testPC1"

I get the error:

Get-DnsServerResourceRecord : The zone mi.intra.parent.com was not found on server $DNSServer.

I tried going up a level to just intra.parent.com, but get the response:

Get-DnsServerResourceRecord : Failed to get testPC1 record in intra.parent.com zone on DNSServer server.

So I am looking for suggestions on either querying through all levels of dns zones, or somehow using the other DNS functions on the information returned from the .Net call that seems to be working.

May 1, 2018 at 12:16 am

Did you see Matt's response to your previous post?