Forum Discussion

chohman595's avatar
chohman595
Copper Contributor
Aug 26, 2020

A Strange DNS Result

Trying to collect some DNS information for some maintenance work, I ran into this:

Get-DnsServerResourceRecord -computername myDC -ZoneName contoso.com -rrtype A 
gives
HostName            RecordType Type       Timestamp            TimeToLive      RecordData                                        
--------            ---------- ----       ---------            ----------      ----------      
machine1            A          1          10/25/2009 6:00:0... 00:20:00        192.168.22.180                                    
machine2            A          1          5/9/2019 5:00:00 AM  00:20:00        192.168.20.50                                     
machine3            A          1          12/6/2019 7:00:00 AM 00:20:00        192.168.44.53 

Get-DnsServerResourceRecord -computername myDC -ZoneName contoso.com -rrtype A | Select HostName,RecordData
gives
HostName                   RecordData              
--------                   ----------              
Machine1                   DnsServerResourceRecordA
Machine2                   DnsServerResourceRecordA
MAchine3                   DnsServerResourceRecordA

 I am not sure what I am missing. Using a ConvertToCSV instead of Select does the same substitution for the data.

Please explain what I did wrong.

Thanks.

  • Hi chohman595 

     

    IPv4Address isn't a string value in RecordData. That's the what you are missing.

    Could you try that way?

     

    Get-DnsServerResourceRecord -ComputerName myDC -ZoneName "contoso.com" -RRType A | Select-Object Hostname,@{Name="IPv4Address";Expression={$_.RecordData.IPv4Address.IPAddressToString }}

     

     

    Thanks.

Resources