PowerShell Genie

NetTCPIP module: setup and commands

Module 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Diagnose addresses, routes and TCP connections with Get-NetIPAddress, Get-NetRoute and Get-NetTCPConnection using the correct interface context.

Getting it

Ships with Windows 8 and Windows Server 2012 onward and loads on demand. There is no equivalent module on Linux or macOS.

Examples

1PS> Get-NetAdapter
Show reference output
1 Name Status LinkSpeed InterfaceIndex
2 -------- ------------ --------- --------------
3 Ethernet Up 1 Gbps 12
4 Wi-Fi Disconnected 0 bps 17
1PS> Test-NetConnection server01 -Port 443
Show reference output
1 ComputerName : server01
2 RemoteAddress : 10.20.30.11
3 RemotePort : 443
4 InterfaceAlias : Ethernet
5 SourceAddress : 10.20.30.41
6 TcpTestSucceeded : True

What it is for

Use it to answer whether an address, a route, or a listening socket is what you expected. Test-NetConnection is the quickest way to separate a name resolution problem from a port reachability problem in a single call.

Typical tasks

  • List IPv4 addresses per interface
  • Inspect the default route and its metric
  • Find which process owns a listening port
  • Test a TCP port against a remote host
  • Group established connections by remote address
  • Check for duplicate or tentative addresses

Check the installed version

1PS> Get-Module -ListAvailable NetTCPIP | Select-Object Name, Version, Path
2PS> Get-Command -Module NetTCPIP

Compare the module path and version with the session used by your scheduled task or automation account. Use it to answer whether an address, a route, or a listening socket is what you expected. Test-NetConnection is the quickest way to separate a name resolution problem from a port reachability problem in a single call.

Primary documentation

Windows services and processes documentation

Continue
Genie guideNetTCPIP module: setup and commands

Diagnose addresses, routes and TCP connections with Get-NetIPAddress, Get-NetRoute and Get-NetTCPConnection using the correct interface context.