Windows PowerShell common networking commands

Windows PowerShell  common networking commands (IPCONFIG, PING, TRACERT, ROUTE NSLOOKUP,NETSTAT)

Network Engineer to trouble shoot some of Windows Servers issue apart from Networking Devices. Maybe you need to check the IP address of a machine or test if its networking connection is working. Maybe you need to see if DNS is properly configured or check the latency between two hosts.

If you have been in this field long enough, you probably have a few favorite commands that you learned years ago and use on a regular basis, like IPCONFIG or PING.

There are literally hundreds of networking-related PowerShell cmdlets in Windows these days. Just try out this command on your machine:

Get-Command -Module Net* | Group Module   – Give you all the list available in your Windows Servers or Windows 10

But more important than knowing every one of them, is to know the most useful cmdlets that have the potential to replace those old commands that you can’t live without.

Only PowerShell can do that you’ll find amazing new troubleshooting abilities…


Description: This command has many options, but the most common usage is just to show the IP address, subnet mask and default gateway for each network adapter in a machine.

PowerShell: Get-NetIPConfiguration or Get-NetIPAddress

Sample command lines:

  • Get-NetIPConfiguration
  • Get-NetIPAddress | Sort InterfaceIndex | FT InterfaceIndex, InterfaceAlias, AddressFamily, IPAddress, PrefixLength -Autosize
  • Get-NetIPAddress | ? AddressFamily -eq IPv4 | FT –AutoSize
  • Get-NetAdapter Wi-Fi | Get-NetIPAddress | FT -AutoSize


Description: Checks connectivity to a specific host. Commonly used to check for liveliness, but also used to measure network latency.

PowerShell: Test-NetConnection

Sample command lines:

  • Test-NetConnection
  • Test-NetConnection -ComputerName -InformationLevel Detailed
  • Test-NetConnection -ComputerName | Select -ExpandProperty PingReplyDetails | FT Address, Status, RoundTripTime
  • 1..10 | % { Test-NetConnection -ComputerName -RemotePort 80 } | FT -AutoSize


Description: Name server lookup. Mostly used to find the IP address for a given DNS name (or vice-versa). Has many, many options.

PowerShell: Resolve-DnsName

Sample command lines:

  • Resolve-DnsName
  • Resolve-DnsName -type SOA
  • Resolve-DnsName  -Server –Type A


Description: Shows the IP routes in a given system (also used to add and delete routes)

PowerShell: Get-NetRoute (also New-NetRoute and Remove-NetRoute)

Sample command lines:

  • Get-NetRoute -Protocol Local -DestinationPrefix 192.168*
  • Get-NetAdapter Wi-Fi | Get-NetRoute


    Description: Trace route. Shows the IP route to a host, including all the hops between your computer and that host.

    PowerShell: Test-NetConnection –TraceRoute

    Sample command lines:

    • Test-NetConnection –TraceRoute
    • Test-NetConnection -TraceRoute | Select -ExpandProperty TraceRoute | % { Resolve-DnsName $_ -type PTR -ErrorAction SilentlyContinue }


    Description: Shows current TCP/IP network connections.

    PowerShell: Get-NetTCPConnection

    Sample command lines:

    • Get-NetTCPConnection | Group State, RemotePort | Sort Count | FT Count, Name –Autosize
    • Get-NetTCPConnection | ? State -eq Established | FT –Autosize
    • Get-NetTCPConnection | ? State -eq Established | ? RemoteAddress -notlike 127* | % { $_; Resolve-DnsName $_.RemoteAddress -type PTR -ErrorAction SilentlyContinue }

It is very interesting to know these commands in Powershell.

I have tested some range to ping using Powershesll below command sweeps all the range of

Test1.ps1 script will ping all the devices in the network of
$subnet = “”
$start = 0
$end = 254
$ping = 1
while ($start -le $end) {
$IP = “192.168.1.$start”
Write-Host “Pinging $IP” -ForegroundColor Cyan
Test-Connection -ComputerName $IP -count 1 -Quiet



Happy Labbing !