Last active
November 23, 2024 16:09
-
-
Save randomvariable/be90107fd57a4f9502af2eba62978fb6 to your computer and use it in GitHub Desktop.
DNS Client Logging on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Start-DNSClientLog { | |
$DnsOpLog = Get-WinEvent -ListLog Microsoft-Windows-DNS-Client/Operational | |
$DnsOpLog.IsEnabled = $true | |
$DnsOpLog.SaveChanges() | |
} | |
function Get-DNSClientQueries { | |
foreach($event in (get-winevent Microsoft-Windows-DNS-Client/Operational | % { [xml]$_.ToXml() })) { | |
$Query = ($event.Event.EventData.Data | Where-Object { $_.Name -eq "QueryName" }).'#text' | |
if($null -eq $Query) { return } | |
New-Object PSObject -Property @{ | |
"Date" = [DateTime]$event.Event.System.TimeCreated.SystemTime; | |
"Query" = $Query | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment