Aug 26 2020 10:38 AM
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.
Sep 07 2020 12:42 AM - edited Sep 07 2020 01:52 PM
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.