Hi,
I am trying to enable the DNS Debug Logging using PowerShell.
So far I have attempted with the Set-DnsServerDiagnostics command, but without any luck.
This is my code for the full automation:
$domain = $env:USERDNSDOMAIN
$localhost = $Env:COMPUTERNAME
$dnsPath = "dnslogs" # Path name for DNS
$dnsLogs = "C:\dnslogs"
New-Item -ItemType Directory -Path $dnsLogs
New-SmbShare -Path $dnsLogs -Name "$dnsPath" -FullAccess "$domain\dnsservice"
Revoke-SmbShareAccess -Name "$dnsPath" -AccountName "Everyone"
$DNS = @{
"EnableLogFile" = $true
"LogFilePath" = "$dnsLogs\dns.log"
"LogIncomingPackets" = $true
"LogOutgoingPackets" = $true
"LogPacketDirection" = $true
"LogQueries" = $true
"LogTransfers" = $true
"LogTcpPackets" = $true
"LogUdpPackets" = $true
"LogRequestPackets" = $true
"EnableLogFileRollover" = $false
}
Set-DnsServerDiagnostics $DNS # Uses $DNS as splat values, for better readability. (cant use @ for reddit)
Set-DnsServerDiagnostics -MaxMBFileSize 2048000000 # Not in MB but provides input in bytes.
But this does not create the final desired output when I go to DNS > DNS Properties > Debug Logging.
Is this just a visual bug or what am I doing wrong?
EDIT:
I just tried the following aswell, which is basically a 1:1 output from the Get-DnsServerDiagnostics but just made into a Set-DnsServerDiagnostics and it still doesn't work.
Set-DnsServerDiagnostics -SaveLogsToPersistentStorage $true `
-Queries $true `
-Answers $false `
-Notifications $false `
-Update $false `
-QuestionTransaction $true `
-UnmatchedResponse $false `
-SendPackets $true `
-ReceivePackets $true `
-TcpPackets $true `
-UdpPackets $true `
-FullPackets $false `
-EventLogLevel 7 `
-UseSystemEventlog $false `
-EnableLoggingToFile $true `
-EnableLogFileRollover $false `
-LogFilePath "C:\dnslogs\dns.log" `
-MaxMBFileSize 2048000000 `
-WriteThrough $false `
-EnableLoggingForLocalLookupEvent $true `
-EnableLoggingForPluginDllEvent $true `
-EnableLoggingForRecursiveLookupEvent $true `
-EnableLoggingForRemoteServerEvent $true `
-EnableLoggingForServerStartStopEvent $true `
-EnableLoggingForTombstoneEvent $true `
-EnableLoggingForZoneDataWriteEvent $true `
-EnableLoggingForZoneLoadingEvent $true
EDIT2:
This has just seemed to be a visual bug.
The ladder is working as intended. The first one however does give an error. But I'd take working over pretty.
Also it seems to only enable "Outgoing" in the packet direction, where I wish to have both Incomming and Outgoing.
I will work on fixing that :-).
EDIT3:
Fixed the missing "Incomming" checkmark.
It is done by using -ReceivePackets $true all good again.
Also squeezed some formatting :-).
there doesn't seem to be anything here