DNS Resolution Check
This script verifies DNS resolution for a list of hostnames (stored in hostnames.txt). It can be helpful when troubleshooting DNS issues or verifying that specific domain names are reachable.
# Path to the file containing hostnames
$hostnameList = Get-Content -Path "C:\Path\To\hostnames.txt"
foreach ($hostname in $hostnameList) {
try {
$resolvedIP = [System.Net.Dns]::GetHostAddresses($hostname)
Write-Output "$hostname resolved to IP: $($resolvedIP.IPAddressToString)"
} catch {
Write-Output "DNS resolution failed for $hostname"
}
}
• Update "C:\Path\To\hostnames.txt" with the path to your file.
• Explanation: This script attempts to resolve each hostname to an IP address and outputs the result.
Last updated