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. 🙂
1 2 3 |
#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}} |
1 2 3 4 5 |
#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}} |