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

Script to Backup Exchange Server

REM exchange.txtD:\Exchange2010\mailbox\TempDatabaseD:\Exchange2010\mailbox\Mailbox-Database-20150403D:\Exchange2010\mailbox\Public Folder Database 1998117930 REM exchangebackup.batecho offnet use S: \\FILESERVER01\backups\EXCHANGE-2010REM -------------------------------------------------------REM PARSE THE DATE…

Basic CSS: Inherit Styles from the Body Element

<style>body {background-color: black;}</style>

SQL AlwayOn High Availability Default Port

Internal SQL DEV & QA environments may have SQL listening to the default port of…