powershell command for network diagnostics
Test-NetConnection are useful in many ways
To get detail information
Test-NetConnection -ComputerName www.contoso.com -InformationLevel Detailed
To check for TraceRoute - shows you the path to the destination server, in this case www.contoso.com.
As traceroute operates on layer 3, it will be good to ensure connectivity is good, before proceeding to troubleshoot network connectivity at a higher level like DNS. (layer 7).
Test-NetConnection -ComputerName www.contoso.com -TraceRoute
Route diagnostics
Test-NetConnection -ComputerName www.contoso.com -DiagnoseRouting -InformationLevel Detailed
or if you want to limit it to a specific network adapter (constraint interface)
Test-NetConnection -ComputerName www.contoso.com -ConstrainInterface 6 -DiagnoseRouting -InformationLevel Detailed
To test for a connectivity to a server, you can try to use
Test-Connection -TargetName www.google.com -Traceroute
To resolve a host
resolve-dnsname test.com
Sometimes people tend to put things in the host file and that can be an issue sometimes. To do dns lookup without using local host file,
resolve-dnsname test.com -NoHostsFile
To resolve dns against another dns server
resolve-dsname test.com -Server my-custom-dns-server
In the window network, it falls back to using netbios. To avoid that, use
resolve-dnsname test.com -DnsOnly
For more information, please use this link
https://learn.microsoft.com/en-us/powershell/module/dnsclient/resolve-dnsname?view=windowsserver2022-ps
There are other commands that might be of interest such as Get-NetTCPConnection, Get-NetRoute and Find-NetRoute
Proxy connectivity
To test for proxy you can use Invoke-WebRequest command
$myCreds=New-Object System.Management.Automation.PSCredential -ArgumentList "Domain\name",$secPasswd
Invoke-WebRequest -URI
www.google.com -Proxy 'http://ipadress:port' -ProxyCredential $mycreds
Comments