Difference between revisions of "Windows dns export zones to rfc"
Jump to navigation
Jump to search
(Created page with "``` $ErrorActionPreference = "Stop" $dnshost = "txv-dc02" New-Item -ItemType Directory -Force -Path ${PWD}/exports $Session = New-PSSession -ComputerName "$dnshost" Functio...") |
|||
Line 2: | Line 2: | ||
$ErrorActionPreference = "Stop" | $ErrorActionPreference = "Stop" | ||
− | $dnshost = " | + | $dnshost = "mydnshostname" |
New-Item -ItemType Directory -Force -Path ${PWD}/exports | New-Item -ItemType Directory -Force -Path ${PWD}/exports | ||
$Session = New-PSSession -ComputerName "$dnshost" | $Session = New-PSSession -ComputerName "$dnshost" |
Revision as of 15:59, 10 February 2023
$ErrorActionPreference = "Stop" $dnshost = "mydnshostname" New-Item -ItemType Directory -Force -Path ${PWD}/exports $Session = New-PSSession -ComputerName "$dnshost" Function exportZones(){ $primaryDnsZones = @() $primaryDnsZones=(Get-DnsServerZone | Where-Object {($_.ZoneType -eq "Primary" -and $_.ZoneName -ne "TrustAnchors")}).ZoneName foreach ($zone in $primaryDnsZones){ echo "Exporting zone: $zone" $file="C:\Windows\System32\dns\$zone" rm $file Export-DnsServerZone -Name "$zone" -FileName "$zone" } } Invoke-Command -ComputerName $dnshost ` -ScriptBlock ${Function:exportZones} Copy-Item -Force "C:\Windows\System32\dns\*" -Exclude *.log,backup,samples,cache.dns -Destination "${PWD}\exports\" -FromSession $Session