Created
February 19, 2016 02:26
-
-
Save chrisbrownie/84d5325ca5123e23f320 to your computer and use it in GitHub Desktop.
Basics of parsing a Windows DNS Log file. Not good, but should be enough to jog the ol' memory.
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
$logFile = "dns2_cleaned.log" | |
$sr = New-Object System.IO.StreamReader($logFile) | |
$line = $sr.ReadLine() | |
$packets = @() | |
while ($line -ne $null) { | |
$line = $line -replace '\s+', ' ' | |
$linebits = $line.Split(" ") | |
$packets += New-Object -TypeName PSObject -Property @{ | |
"Protocol" = $linebits[6] | |
"Direction" = $linebits[7] | |
"Client" = $linebits[8] | |
"RecordType" = if ($linebits[10] -eq "R") { $linebits[16] } else { $linebits[14]} | |
} | |
$line = $sr.ReadLine() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment