VMware Cloud Community
esxi1979
Expert
Expert
Jump to solution

Powershell community

Anyone knows most active (like ours) community for powershell  ?

If May ask ...

when i ran

Get-DnsServerZone -ComputerName  xxx| ? {$_.zonename -like '*in-addr.arpa'} | Get-DnsSe

rverResourceRecord -ComputerName  xxx -RRType PTR

i get the RecordData info ... but when i do export csv to it, i do not get the hostname but get nsServerResourceRecordPtr

HostNameRecordClassRecordDataRecordTypeTimestampTimeToLivePSComputerName
66INDnsServerResourceRecordPtrPTR1:00:00

Also if u look at this .. i need the hostname as complete in-addr* than just 66 (last digit of the /24 )

Please guide

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The property RecordData contains an object, and Export-Csv doesn't know how to handle this, so it gives the typename of that object in the CSV.

If you need to access nested properties, one way of doing that is with a calcuated property on a Select-Object cmdlet.

Something like this

Get-DnsServerZone -ComputerName dc1.local.test | where{$_.ZoneName -match 'in-addr.arpa'} |

Get-DnsServerResourceRecord -ComputerName dc1.local.test -RRType Ptr |

Select HostName,RecordType,Timestamp,TimeToLIve,@{N='PtrDomainName';E={$_.RecordData.PtrDomainName}} |

Export-Csv report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
6 Replies
esxi1979
Expert
Expert
Jump to solution

if i give select in the statement i get

53                                                      DnsServerResourceRecordPtr
61                                                      DnsServerResourceRecordPtr
65                                                      DnsServerResourceRecordPtr
66                                                      DnsServerResourceRecordPtr
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The property RecordData contains an object, and Export-Csv doesn't know how to handle this, so it gives the typename of that object in the CSV.

If you need to access nested properties, one way of doing that is with a calcuated property on a Select-Object cmdlet.

Something like this

Get-DnsServerZone -ComputerName dc1.local.test | where{$_.ZoneName -match 'in-addr.arpa'} |

Get-DnsServerResourceRecord -ComputerName dc1.local.test -RRType Ptr |

Select HostName,RecordType,Timestamp,TimeToLIve,@{N='PtrDomainName';E={$_.RecordData.PtrDomainName}} |

Export-Csv report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
esxi1979
Expert
Expert
Jump to solution

Thanks LucD !!!       Is it possible to get the complete RR domain ie in-addr.arpaXXXX than just the last octate in the above ?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Like this you mean ?

&{foreach($zone in (Get-DnsServerZone -ComputerName dc1.local.test | where{$_.ZoneName -match 'in-addr.arpa'})){

    Get-DnsServerResourceRecord -ZoneName $zone.ZoneName -ComputerName dc1.local.test -RRType Ptr |

    Select @{N='HostName';E={"$($zone.ZoneName).$($_.HostName)"}},RecordType,Timestamp,TimeToLIve,@{N='PtrDomainName';E={$_.RecordData.PtrDomainName}}

}} | Export-Csv report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

esxi1979
Expert
Expert
Jump to solution

Perfect ! Thanks !!

Reply
0 Kudos