Created
March 15, 2020 20:18
-
-
Save CJHarmath/52bd076e40032abb80a3d43aa40183e4 to your computer and use it in GitHub Desktop.
DNS Resolve Test
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 Test-DnsResolve($name, $server) { | |
<# | |
.SUMMARY | |
DNS Resolver tester | |
.PARAMETER Name | |
The host name to resolve | |
.PARAMETER Server | |
The DNS Server to be used | |
#> | |
$lastIp = $null | |
while($true) { | |
& ipconfig /flushdns | out-null | |
$resolved = (Resolve-DnsName $name -server $server).IpAddress | |
if ($lastIp -ne $resolved) { | |
Write-Host $resolved | |
(Invoke-RestMethod "https://geolocation-db.com/jsonp/$resolved") | |
$lastIp = $resolved | |
} | |
start-sleep -Seconds 1 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment