Last active
December 13, 2016 10:40
-
-
Save Sam-Martin/75d18dc0e96018800f3d2ec156c4c04a to your computer and use it in GitHub Desktop.
Establish BIND records' resolvability
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
$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