Skip to content

Instantly share code, notes, and snippets.

@rmbolger
Created June 7, 2019 13:24
Show Gist options
  • Save rmbolger/f3bb07015c8905f3b82a81e25e6b78a8 to your computer and use it in GitHub Desktop.
Save rmbolger/f3bb07015c8905f3b82a81e25e6b78a8 to your computer and use it in GitHub Desktop.
Parses the netlogon.dns file on an Active Directory domain controller to display a nicely formatted and sorted list of required DNS records for that DC
gc "$($env:SYSTEMROOT)\System32\config\netlogon.dns" | %{ $p = $_.Split(' '); $d = ($p[4..($p.Count-1)] -join ' '); [pscustomobject]@{name=$p[0].Trim('.').Split('.');ttl=$p[1];type=$p[3];data=$d} } | sort @{E={$a=@()+$_.name;[Array]::Reverse($a);$a}},type,data | select @{L='rec';E={$_.name[0]}},@{L='zone';E={$_.name[1..($_.name.Count-1)] -join '.'}},ttl,type,data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment