Skip to content

Instantly share code, notes, and snippets.

@Sam-Martin
Last active December 13, 2016 10:40
Show Gist options
  • Save Sam-Martin/75d18dc0e96018800f3d2ec156c4c04a to your computer and use it in GitHub Desktop.
Save Sam-Martin/75d18dc0e96018800f3d2ec156c4c04a to your computer and use it in GitHub Desktop.
Establish BIND records' resolvability
$zone = gc .\fmlocal.zone | ?{$_ -notmatch '(^;|^-|^\s*$|^@|^\$|^\s+)'} | %{$val = $_ -split '\s+'; new-object psobject -Property @{"Name"=$val[0];"Value"=$val[3] }}
foreach($record in $zone) {
$nslookup = $(nslookup "$($record.name).fmlocal" 2>&1 | out-string)
$matches = @();
$nslookup -match '(?smi)(?<Name>Name:.*)(Address:\s*)(?<Address>[0-9\.]*)' | Out-Null
if(!$matches){
$record | select *,@{L="Resolvable";E={$false}}, @{L="Resolved Address";E={$null}}
}else{
$record | select *,@{L="Resolvable";E={$true}}, @{L="Resolved Address";E={$Matches.Address}}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment