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