Operations 5 min read

Master Windows Network Troubleshooting with PowerShell: 10 Essential Cmdlets

This guide walks you through ten powerful PowerShell cmdlets for diagnosing and fixing Windows network issues, covering ping tests, port checks, traceroutes, IP configuration, DNS queries, TCP connections, DNS settings, cache clearing, DHCP lease management, and network adapter control.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Windows Network Troubleshooting with PowerShell: 10 Essential Cmdlets

1. Ping local or remote devices

The Test-NetConnection -ComputerName "Hostname or IP" cmdlet performs a ping to verify connectivity between the local machine and a target host or domain.

2. Check port or service connectivity

Use Test-NetConnection "Hostname" -Port # to test whether a specific port on the remote host is reachable, helping identify service availability issues.

3. Trace the route

Execute Test-NetConnection "Hostname" -Traceroute to display each hop a packet takes to reach the destination, pinpointing where a connection may be failing.

4. Retrieve detailed IP configuration

The Get-NetIPConfiguration cmdlet provides a comprehensive view of network adapters, showing IP, DNS, and gateway addresses sorted by adapter name.

5. Perform DNS lookups

Run Resolve-DnsName -Name "Hostname" to query DNS records; adding -Server <em>DNS_Server_IP</em> lets you target a specific DNS server for verification.

6. View current TCP connections

Get-NetTCPConnection

lists active and listening TCP connections, aiding in troubleshooting port‑related problems.

7. Inspect and set DNS client information

Use Get-DnsClient to see which DNS servers each adapter uses, and Set-DnsClientServerAddress to assign new DNS server addresses.

8. Clear the DNS cache

Clear-DnsClientCache

removes stored DNS records, ensuring the system performs fresh lookups and avoids issues caused by stale entries.

9. Release and renew DHCP leases

Although PowerShell lacks a direct DHCP cmdlet, you can invoke the classic ipconfig /release and ipconfig /renew commands remotely with

Invoke-Command -ComputerName <em>Target</em> -ScriptBlock { ipconfig /release }

and similarly for renewal.

10. Disable and enable network adapters

Finally, Disable-NetAdapter -Name "Adapter Name" and Enable-NetAdapter -Name "Adapter Name" let you reset a network interface, a simple yet often effective way to resolve connectivity problems.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

network troubleshootingWindowsIT OperationsPowerShellCmdlet
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.