mandag den 21. marts 2011

AXFR Zone Transfers from PowerShell

So I’m playing around with a script to transfer a zone from another DNS server to my own DNS servers. I’m using DnsShell for most of my operation’s ( it has a few bugs, but nothing that cant be handled by adding abit of WMI  ) but I couldn’t get AXFR requests to work. google sendt me to PowerShell Dig PoshNet but that didn’t work either, and then it hit me (I can be so slow sometimes), I can’t AXFR from my default DNS server I need to ask hosting DNS server, and no need to bother with different PSSnapins. DnsShell does the work just fine. Here is an example.

$zonename = ‘somedomain.com’
$nameservers = (Get-Dns $zonename ns) | Select-Object -ExpandProperty Answer
$dnsserver = (get-dns $nameservers[0].RecordData).Answer[0].RecordData
Write-Host (‘Asking ‘ + $nameservers[0].RecordData + ' ' + $dnsserver)
$zone = Get-Dns -Name $zonename -RecordType axfr -Server $dnsserver | Select-Object -ExpandProperty Answer
$zone

Ingen kommentarer:

Tilføj en kommentar