#Requires -Version 5.1 <# JbTecWiz Support Centre -- read-only diagnostic Fault : Websites do not load but the IP address pings -- DNS resolution failure Source: https://jbtecwiz.com/support/win-net-dns-only This script CHANGES NOTHING. It runs only the inspection commands from the write-up -- the Get-, Test- and Resolve- calls that establish which cause is in play -- and prints what each returned. Anything that writes, deletes, starts or stops is excluded by construction, not by judgement. Read the output alongside the write-up, then pick the fix that matches. Each fix has its own script on the same page. -------------------------------------------------------------------- NO WARRANTY - USE AT YOUR OWN RISK This script is provided by JbTecWiz as-is and with no warranty of any kind, express or implied. You run it entirely at your own risk. JbTecWiz accepts no liability for any loss or damage arising from its use, including but not limited to data loss, downtime, or configuration changes that turn out to be wrong for your system. You are responsible for reading this script before running it, for satisfying yourself that it suits the machine in front of you, and for having a working backup first. Some steps cannot be undone. -------------------------------------------------------------------- #> [CmdletBinding()] param([switch]$Transcript) $ErrorActionPreference = 'Continue' if ($Transcript) { $log = Join-Path $env:USERPROFILE ("jbtecwiz-win-net-dns-only-" + (Get-Date -Format yyyyMMdd-HHmmss) + ".txt") Start-Transcript -Path $log | Out-Null Write-Host (' Saving a transcript to ' + $log) } function Write-Rule { param([string]$Text) Write-Host '' Write-Host ('-' * 70) -ForegroundColor DarkGray if ($Text) { Write-Host $Text -ForegroundColor Cyan } } function Probe { param([string]$Label, [string]$Fix, [scriptblock]$Command) Write-Rule (" " + $Label) Write-Host (" from: " + $Fix) -ForegroundColor DarkGray Write-Host '' foreach ($l in ($Command.ToString().Trim() -split "`n")) { Write-Host (" " + $l.Trim()) -ForegroundColor DarkGreen } Write-Host '' try { $out = & $Command 2>&1 | Out-String if ([string]::IsNullOrWhiteSpace($out)) { Write-Host ' (returned nothing)' -ForegroundColor DarkGray } else { foreach ($l in ($out.TrimEnd() -split "`n")) { Write-Host (" " + $l.TrimEnd()) } } } catch { Write-Host (" could not run: " + $_.Exception.Message) -ForegroundColor Yellow } } Write-Rule Write-Host ' Websites do not load but the IP address pings -- DNS resolution failure' -ForegroundColor White Write-Host ' Read-only diagnostic -- nothing is changed.' -ForegroundColor Green Write-Rule Probe -Label 'Look at what is actually cached before clearing it -- this often names the culprit.' -Fix 'Clear the resolver cache and the poisoned entries in it' -Command { Get-DnsClientCache | Where-Object Entry -notlike '*.local' | Select-Object -First 30 Entry,Data,TimeToLive } Probe -Label 'Check the hosts file. An entry here beats DNS entirely and survives every cache flush.' -Fix 'Clear the resolver cache and the poisoned entries in it' -Command { Get-Content $env:WINDIR\System32\drivers\etc\hosts | Where-Object { $_ -notmatch '^\s*#' -and $_.Trim() } } Probe -Label 'Ask the configured server directly, then ask a public one, and compare.' -Fix 'Clear the resolver cache and the poisoned entries in it' -Command { Resolve-DnsName jbtecwiz.com Resolve-DnsName jbtecwiz.com -Server 1.1.1.1 } Probe -Label 'Verify: Both queries return the same address and browsing works.' -Fix 'Clear the resolver cache and the poisoned entries in it' -Command { Resolve-DnsName outlook.office365.com | Select-Object -First 3 Name,Type,IPAddress } Probe -Label 'Test each configured server before changing anything.' -Fix 'Point the machine at DNS servers it can actually reach' -Command { Test-NetConnection 10.0.0.10 -Port 53 -InformationLevel Detailed } Probe -Label 'Verify: Names resolve and the internal ones still work if this is a domain machine.' -Fix 'Point the machine at DNS servers it can actually reach' -Command { Resolve-DnsName $env:USERDNSDOMAIN -Type SOA } Write-Rule Write-Host ' Diagnostic finished. Nothing was changed.' -ForegroundColor Green Write-Host '' Write-Host ' Compare the output above with the write-up, then run the' Write-Host ' script for the fix that matches:' Write-Host ' https://jbtecwiz.com/support/win-net-dns-only' Write-Rule if ($Transcript) { Stop-Transcript | Out-Null }