DNS : Command Lines

Bunch of differents command lines relative to Windows DNS Srevers I’m oftently using

Create a Windows Server Condtional forwarders zone
Add-DnsServerConditionalForwarderZone -Name test.com -MasterServers 1.1.1.1,8.8.8.8 -ReplicationScope Forest
Export “DNS Server” Eventlog of a Windows DNS Server in a CSV file
Get-WinEvent -ComputerName DNSServer_FQDN -LogName "DNS Server" | Select-Object TimeCreated, Id, LevelDisplayName, ProviderName, Message | Export-Csv -Path C:\Temp\DNS-Events.csv -NoTypeInformation
List Windows DNS Server Zones
Get-DnsServerZone -ComputerName DNSServer_FQDN
List Windows DNS Server Conditional forwarders zones with IP addresses (WMI)
gwmi -computername DNSServer_FQDN -Namespace root\MicrosoftDNS -Class MicrosoftDNS_Zone -Filter "ZoneType = 4" |Select -Property @{n='Name';e={$_.ContainerName}}, @{n='DsIntegrated';e={$_.DsIntegrated}}, @{n='MasterServers';e={([string]::Join(',', $_.MasterServers))}}, @{n='AllowUpdate';e={$_.AllowUpdate}}
List Windows DNS Server Forwarders
Get-DnsServerForwarder
Remove Windows DNS Server Zone
Remove-DnsServerZone -computername DNSServer_FQDN -Name NameOfTheZone
Set DNS Servers on a Windows client computer
Get-NetAdapter | fl Name, InterfaceIndex
Set-DnsClientServerAddress -InterfaceIndex "XXX" -ServerAddresses ("1.1.1.1","8.8.8.8,"10.10.10.10")
Show Windows DNS Server cache
Show-DnsServerCache -computername DNSServer_FQDN
Show Windows DNS Server configuration details
Get-DnsServer -computername DNSServer_FQDN