PowerShell – Windows DNS Server Basics

| | | |
# Windows Version - Helps to know what version as some things change from one version to another.
(Get-WmiObject -class Win32_OperatingSystem).Caption

$ZN = "kittell.net"

# List DNS Forwarders - Where to go if DNS record not in this DNS server
Get-DnsServerForwarder

# Remove DNS Server Forwards
#Remove-DnsServerForwarder -IPAddress 8.8.8.8 -PassThru -Force
#Remove-DnsServerForwarder -IPAddress 9.9.9.9 -PassThru -Force
#Get-DnsServerForwarder

Add-DnsServerForwarder -IPAddress 8.8.8.8 -PassThru

# List all records on DNS server
Get-DnsServerResourceRecord -ZoneName $ZN

# List only SOA records on DNS server
Get-DnsServerResourceRecord -ZoneName $ZN -RRType SOA | FL

# List Zone Delegation 
Get-DnsServerZoneDelegation -Name $ZN

# Setup Zone Delegation
Add-DnsServerZoneDelegation -Name $ZN -ChildZoneName "_msdcs" -NameServer "dns01.$ZN" -IPAddress 10.25.254.208 -PassThru -Verbose
Add-DnsServerResourceRecordA -ZoneName $ZN -TimeToLive 01:00:00 -AllowUpdateAny -Name "dns02"  -IPv4Address "10.25.254.209"

# Get full DNS server configuration
Get-DnsServer | Export-Clixml -Path "$HOME\Desktop\DnsServerConfig.xml"
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.