Quantcast
Channel: Rob V IT
Viewing all articles
Browse latest Browse all 64

Check DNS Entries with PowerShell

$
0
0

In a dynamic environment it’s hard to keep your DNS up-to-date. Updating the DNS server is a task which is mostly forgotten during server maintenance.
Created just a simple one-liner for checking the registered suffix and do a ping test.

Yeah I know this one is not dummy proof, but hey! t helped me checking 10.000 records in 2 minutes, so maybe i can help someone with sharing this. 🙂

#Without suffix check
get-adcomputer -filter * | select -expandproperty DNSHostname | % { $_ ; try { ([System.Net.Dns]::GetHostAddresses($_)).IPAddressToString } Catch { write-host "DNS Suffix not OK" -foregroundcolor Red } ; `
if(test-connection -computername $_ -count 1 -Quiet){ } else{write-host "Failed to ping $_" -foregroundcolor red}}

#With hardcoded suffix check
$suffix = "YOURDNSSUFFIX"
get-adcomputer -filter * | % { ($a = ($_.dnshostname).split(".").toupper()[0] + $suffix ) ;  `
try { ([System.Net.Dns]::GetHostAddresses($a)).IPAddressToString } Catch { write-host "DNS Suffix not OK" -foregroundcolor Red } ; `
if(test-connection -computername $a -count 1 -Quiet){ } else{write-host "Failed to ping $a" -foregroundcolor red}}

 

The post Check DNS Entries with PowerShell appeared first on Rob V IT.


Viewing all articles
Browse latest Browse all 64

Trending Articles