Posted On January 6, 2020

PowerShell: Check if a HostName is Resolvable on All Internal DNS Servers

kimconnect 0 comments
blog.KimConnect.com >> Codes , Networking >> PowerShell: Check if a HostName is Resolvable on All Internal DNS Servers
# Check if servername is resolvable at all DCs

$serverName="MIGRATED-SHERVER"

function checkDns{
param(
$serverName,
$dnsServers=(Get-ADDomainController -Filter *).Name
)
$results="";
$dnsServers|%{
$resolve=Resolve-DnsName -Name $serverName -Server $_ -QuickTimeout -ea SilentlyContinue

$result=if($resolve.Name -ne $null){
"$_ has records of $serverName as $($resolve.IPAddress)`: Yes!`r`n";
}else{"$_ has records of $serverName`: No!`r`n";}
write-host $result -NoNewline;
$results+=$result;
}
return $results
}

checkDns -servername $serverName
checkDns -servername $serverName

Sample Result:

PS C:\temp> checkDns -servername $serverName
DNS001 has NO records of MIGRATED-SHERVER-old
DNS002 has NO records of MIGRATED-SHERVER-old
DNS003 has NO records of MIGRATED-SHERVER-old
DNS004 has NO records of MIGRATED-SHERVER-old
DNS005 has NO records of MIGRATED-SHERVER-old
DNS006 has NO records of MIGRATED-SHERVER-old
DNS007 has NO records of MIGRATED-SHERVER-old


PS C:\temp> checkDns -servername "MIGRATED-SHERVER"
DNS001 has records of MIGRATED-SHERVER
DNS002 has records of MIGRATED-SHERVER
DNS003 has records of MIGRATED-SHERVER
DNS004 has records of MIGRATED-SHERVER
DNS005 has records of MIGRATED-SHERVER
DNS006 has records of MIGRATED-SHERVER
DNS007 has records of MIGRATED-SHERVER

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

JavaScript: Build a Tic Tac Toe Game (without AI)

Demo: https://blog.kimconnect.com/wp-content/projects/ticTacToeGame.html CSS Code: @import url('https://fonts.googleapis.com/css?family=Merienda');body{ font-family: 'Merienda', cursive; font-weight: bold;}#gameBoard { width: 396px; //…

Transfer DHCP Scopes Between Windows Servers

When a new DHCP server is introduced into the system, it's often necessary to configure…

PowerShell: WinHTTP Proxy

The most direct method to set WinHTTP proxy settings on a Windows machine is to…