DNS PowerShell one liner

This is a “one liner” that pulls all the DNS Entries for a particular zone, including the IPv4 and IPv6.  If you don’t care about the IPv6, you can remove that segment of the code.

Get-DnsServerResourceRecord –ComputerName <DNSServerName> –ZoneName <YourZoneName> | Select-Object DistinguishedName,HostName,@{Name=’IPv4Address’;Expression={$_.RecordData.IPv4Address.IPAddressToString}},@{Name=’IPv6Address’;Expression={$_.RecordData.IPv6Address.IPAddressToString}},RecordType,Timestamp,TimeToLive | Export-Csv $env:TEMP\DNSExport.csv –NoTypeInformation

It is amazing how much you can do with just one line (even if the line is obnoxiously long.)

  1. No Comments

%d bloggers like this: