Экспортируйте все хосты из использования менеджера по DNS Powershell

Это должно хорошо работать. У меня была Очень похожая проблема, где окна сталкивались с ошибками файловой системы. Я клонировал диск, уничтожил массив, воссоздал его и восстановил изображение, и все было прекрасно с тех пор. Мой вопрос был ЗДЕСЬ.

4
задан 3 November 2013 в 15:44
3 ответа

Раньше я использовал DNSShell. http://dnsshell.codeplex.com/ . Чтобы получить все записи A в зоне, вы можете сделать следующее:

Get-DnsRecord -RecordType A -ZoneName FQDN -Server ServerName

Чтобы получить это в текстовый файл:

Get-DnsRecord -RecordType A -ZoneName FQDN -Server ServerName | % {Add-Content -Value $_ -Path filename.txt}
6
ответ дан 3 December 2019 в 02:22

Другой метод, о котором я пока не упоминаю:

Get-WmiObject -Namespace Root\MicrosoftDNS -Query "SELECT * FROM MicrosoftDNS_AType WHERE ContainerName='domain.com'"

WMI полезно помнить, когда вы не можете загрузить DnsShell по какой-либо причине или если вы используете более старую версию Powershell в котором нет встроенных командлетов, или если вы ориентируетесь на старую версию Windows Server.

6
ответ дан 3 December 2019 в 02:22

The DnsServer module available in Windows Server 2012, Powershell v3 has the following commands that might be useful to you:

Get-DnsServerZone
Get-DnsServerResourceRecord

The first will get you all the zones The second will get you the records for whatever zone you pass to it

They are basically the equivalent of DNSCMD's /EnumZones and /EnumRecords.

So... You could write something like this to get ALL of the records from ALL zones:

$Zones = @(Get-DnsServerZone)
ForEach ($Zone in $Zones) {
    Write-Host "`n$Zone.ZoneName" -ForegroundColor "Yellow"
    $Zone | Get-DnsServerResourceRecord
}

Also, I'm fairly sure that server 2012 keeps an actual zonefile for each zone now? So you should have a file copy for all your zones.

If you're working with 2008 R2, then you can use this script which I use to back up all of my zones to files:

$zones = @( `
    dnscmd /enumzones | `
    select-string -pattern "\b(?i)((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b" | %{$_.Matches} | %{$_.Value};
);

ForEach ($domain in $zones) {
    $backup = "dnscmd . /zoneExport $domain $domain";
    Invoke-Expression $backup | Out-Null
    Write-Host "Backing up $domain" -ForegroundColor "White"
};

ForEach ($item in (gci C:\Windows\System32\dns)) {
    Write-Host "Renaming $item" -ForegroundColor "White"    
Rename-item $item.fullname ([string]$item + ".dns")
}

Write-Host "Back up complete." -ForegroundColor "Cyan"
cmd /c pause | out-null
4
ответ дан 3 December 2019 в 02:22

Теги

Похожие вопросы