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

Install AWS Command Line Interface on Windoze

Obtain AWS Access Key: Log into AWS > click on your User Name > My…

Python: Package Installer for Python (PIP)

This comes preinstalled with Python 3.4 or higher. Similar to the Microsoft PowerShell Gallery, Python.org…

PowerShell: Get MD5 Hashing Signature of a File

# Get-MD5-Hash.ps1# Get-FileHash (PowerShell 4.0+) replacement for Windows 2008. Forward-compatible.function getMd5{ param( $file, $md5 =…