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
HostName | RecordClass | RecordData | RecordType | Timestamp | TimeToLive | PSComputerName |
66 | IN | DnsServerResourceRecordPtr | PTR | 1: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
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
if i give select in the statement i get
53 | DnsServerResourceRecordPtr |
61 | DnsServerResourceRecordPtr |
65 | DnsServerResourceRecordPtr |
66 | DnsServerResourceRecordPtr |
looks like this is it - https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
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
Thanks LucD !!! Is it possible to get the complete RR domain ie in-addr.arpaXXXX than just the last octate in the above ?
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
Perfect ! Thanks !!