Get-DnsServerResourceRecord - I need the format-table output value of recorddata

Hi,

Powershell Format-Table is doing something automatically, but I cannot figure out how, and how to get the value I need.

Here is a little piece of code:

$zonetoimport = 'myzone.com'
$adzfull = Get-DnsServerResourceRecord -ZoneName $zonetoimport

$adzfull | ft

The last command return a table with these attributes by default:

Hostname, RecordType, TimeStamp, TimetoLive and RecordData (this is where my problem is)

here is a

sample of the output with different RecordType


HostName                  RecordType Timestamp            TimeToLive      RecordData
--------                  ---------- ---------            ----------      ----------

bamboos                    CNAME      0                    01:00:00        operation.myzone.com.
autodiscover             	 A          0                    01:00:00        10.8.50.22
cases-vip         		A          0                    01:00:00        10.2.40.66
_kpasswd._udp             SRV        2/13/2015 8:00:00 AM 00:10:00        [0][100][464][las-ad-1.myzone.com.]
_gc._tcp                  SRV        2/12/2015 2:00:00 PM 00:10:00        [0][100][3268][san-ad-2.myzone.com.]
@                         NS         0                    01:00:00        las-ad-1.myzone.com.
@                         SOA        0                    01:00:00        [2458][san-prod-ad-1.myzone.com.][hostmast...
device.myzone.com  CNAME      0                    01:00:00        server66.myzone.com.
serverala.myzone... TXT        0                    01:00:00        "31343cf2aedfccd72349ecfd073a12bd7fb"

This output is perfect because the RecordData returns  the value I need to work with, unfortunately it gets more complicated and frustrating when I need to work with those values.

I need only to work with 3 attributes: HostName, RecordType and RecordData

then I do a 

$adzfull | ft  HostName, RecordType, RecordData

and there RecordData doesn't show the value I need, but return DnsServerResourceRecordA, DnsServerResourceRecordNS, DnsServerResourceRecordSoa, etc ... instead.

So of course I can do something such as 

$adzfull[0].RecordData.IPv4Address for the A record

$adzfull[1].RecordData.MailExchange for the MX record

$adfull[2].RecordData.HostNameAlias for the CNAME record

etc ...

but than I have to treat each case which is quite painful, especially when " $adzfull | ft " command does it automatically

I wonder if it has something to do with a ps1xml file, but which one ? how to deal with it ?

C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DnsServer has a couple ps1xml and cdxml file

Any help is welcome, Thank you





  • Edited by Cyreli Friday, February 13, 2015 7:50 PM
February 13th, 2015 10:30pm

My post is indeed not that clear, What I need is very simple:

$adzfull | ft => returns RecordData with the value I need to work with

$adzfull | ft RecordData => doesnt return the "correct" data anymore

The default FT output an 10.1.1.1 for a A record

when using ft RecordData, is will only show DnsServerResourceRecordA

I'm sure it has something to do with the file in C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DnsServer

PS_DnsServerResourceRecordAAAA_v1.0.0.cdxml
PS_DnsServerResourceRecordAging_v1.0.0.cdxml
PS_DnsServerResourceRecordA_v1.0.0.cdxml
PS_DnsServerResourceRecordCNAME_v1.0.0.cdxml
PS_DnsServerResourceRecordDnsKey_v1.0.0.cdxml
PS_DnsServerResourceRecordDS_v1.0.0.cdxml
PS_DnsServerResourceRecordMX_v1.0.0.cdxml
PS_DnsServerResourceRecordPTR_v1.0.0.cdxml
PS_DnsServerResourceRecord_v1.0.0.cdxml

  • Edited by Cyreli Friday, February 13, 2015 7:54 PM
Free Windows Admin Tool Kit Click here and download it now
February 13th, 2015 10:53pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics