Skip to content

PowerShell Networking

How PowerShell replaces legacy networking tools like ipconfig, netstat, and ping with structured cmdlets (Get-NetIPAddress, Get-NetTCPConnection) for automated, object-based network management in Windows.

PowerShell replaces legacy text-based networking tools (such as ipconfig, netstat, route, and ping) with structured, object-oriented cmdlets. Most networking functionality comes from the built-in NetTCPIP, NetAdapter, and NetConnection modules, which ship with Windows and expose commands following the standard Verb-Noun convention. Rather than parsing fragile text output, these cmdlets emit strongly-typed .NET and CIM objects that can be piped directly into Where-Object, Sort-Object, Select-Object, or Export-Csv.

Legacy Tools vs. Modern PowerShell Cmdlets

Traditional command-line utilities emit unformatted text strings that require string parsing (using findstr or regular expressions). PowerShell cmdlets output structured objects, allowing direct filtering, sorting, and automation.

Legacy Utility PowerShell Cmdlet Module Primary Purpose
ipconfig Get-NetIPAddress, Get-NetIPConfiguration NetTCPIP / NetAdapter View IP addresses and interface settings
netstat Get-NetTCPConnection, Get-NetUDPEndpoint NetTCPIP Inspect active sockets and listening ports
route Get-NetRoute, New-NetRoute, Remove-NetRoute NetTCPIP Query and manipulate IP routing tables
ping Test-Connection Microsoft.PowerShell.Management Send ICMP echo requests
arp -a Get-NetNeighbor NetTCPIP View IP-to-physical address mappings
nslookup Resolve-DnsName DnsClient Perform DNS record lookups
Consolepowershell
Get-Command -Module NetTCPIP, NetAdapter | Select-Object Name
Outputplaintext
Name
----
Get-NetIPAddress
Get-NetIPConfiguration
Get-NetRoute
Get-NetTCPConnection
Get-NetAdapter
Enable-NetAdapter
Disable-NetAdapter
Restart-NetAdapter
...

Categories of Networking Cmdlets

Category Example Cmdlets Purpose
Connectivity testing Test-Connection, Test-NetConnection Ping hosts, test port availability
IP configuration Get-NetIPConfiguration, Get-NetIPAddress View/set IP settings
Adapter management Get-NetAdapter, Enable-NetAdapter, Disable-NetAdapter Manage network interfaces
Connections & statistics Get-NetTCPConnection, Get-NetAdapterStatistics Inspect active connections and traffic
File sharing New-SmbMapping, Get-SmbMapping Map and manage network drives
Computer identity Get-ComputerInfo, Rename-Computer View/manage machine network identity

Introduction to the NetTCPIP Module

The NetTCPIP module is built into Windows and provides end-to-end control of the TCP/IP network protocol stack, including configuring IP addresses, managing routing tables, querying TCP connections, and fine-tuning network interfaces directly through the pipeline. It is a binary module (backed by compiled code, not a .psm1 file), which is why its cmdlets appear instantly available without an explicit Import-Module: Windows loads it via module auto-loading.

Its cmdlets are divided into specific operational functional groups:

  • IP Addresses (*-NetIPAddress): Query, assign, and remove IPv4 and IPv6 addresses.
  • IP Interfaces (*-NetIPInterface): Configure MTU size, DHCP client behavior, IPv6 router discovery, and interface metrics.
  • Routing Table (*-NetRoute): Create static routes, view the default gateway, and manage next-hop metrics.
  • Neighbor Discovery (*-NetNeighbor): Manage the ARP and IPv6 neighbor cache.
  • Transport Connections (*-NetTCPConnection): Query active TCP sockets, process owners, and state transitions.
discover-nettcpip.ps1powershell
Get-Command -Module NetTCPIP -Verb Get | 
    Select-Object -Property Name, CommandType -First 6

where:

  • Get-Command queries registered cmdlets and functions matching criteria.
  • -Module NetTCPIP scopes command search exclusively to the NetTCPIP module.
  • -Verb Get filters only retrieval cmdlets.
  • Select-Object -First 6 restricts display output to the first six matches.
Consolepowershell
./discover-nettcpip.ps1
Outputplaintext
Name                   CommandType
----                   -----------
Get-NetCompartment        Function
Get-NetIPAddress          Function
Get-NetIPConfiguration    Function
Get-NetIPInterface        Function
Get-NetIPv4Protocol       Function
Get-NetIPv6Protocol       Function

Viewing IP Configuration

The Get-NetIPConfiguration cmdlet is the object-based equivalent of ipconfig, returning structured configuration details per network adapter.

Consolepowershell
Get-NetIPConfiguration
Outputplaintext
InterfaceAlias       : Ethernet
InterfaceIndex       : 12
InterfaceDescription : Intel(R) Ethernet Connection
IPv4Address          : 192.168.1.42
IPv4DefaultGateway   : 192.168.1.1
DNSServer            : 192.168.1.1

Viewing IP Addresses Directly

For a flatter list of assigned IP addresses across all adapters, use Get-NetIPAddress.

Consolepowershell
Get-NetIPAddress -AddressFamily IPv4

where -AddressFamily filters results to IPv4 or IPv6 addresses only.

Outputplaintext
IPAddress         : 192.168.1.33
InterfaceIndex    : 6
InterfaceAlias    : Ethernet0
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 24
PrefixOrigin      : Dhcp
SuffixOrigin      : Dhcp
AddressState      : Preferred
ValidLifetime     : 9.19:38:05
PreferredLifetime : 9.19:38:05
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : 127.0.0.1
InterfaceIndex    : 1
InterfaceAlias    : Loopback Pseudo-Interface 1
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 8
PrefixOrigin      : WellKnown
SuffixOrigin      : WellKnown
AddressState      : Preferred
ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource      : False
PolicyStore       : ActiveStore

Filtering by Adapter Alias

get-ip-summary.ps1powershell
Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias "Ethernet*", "Wi-Fi*" | 
    Select-Object -Property InterfaceAlias, IPAddress, PrefixLength, AddressState

where:

  • Get-NetIPAddress queries configured IP addresses from the network stack.
  • -AddressFamily IPv4 restricts results to IPv4 addresses (excluding IPv6 link-local and global addresses).
  • -InterfaceAlias filters results by adapter name using wildcard matching.
  • Select-Object chooses specific properties for tabular formatting.
Consolepowershell
./get-ip-summary.ps1
Outputplaintext
InterfaceAlias IPAddress    PrefixLength AddressState
-------------- ---------    ------------ ------------
Ethernet0      192.168.1.33           24    Preferred

Inspecting Interface Metrics and Gateways

Network performance and routing priority are determined by interface metrics. Lower metric values indicate higher route priority. The following script identifies all active interfaces, their configured IP addresses, and their associated route metric.

audit-interfaces.ps1powershell
Get-NetIPInterface -AddressFamily IPv4 -ConnectionState Connected | 
    Select-Object -Property InterfaceAlias, InterfaceIndex, InterfaceMetric, Dhcp |
    Sort-Object -Property InterfaceMetric

where:

  • Get-NetIPInterface retrieves configuration settings for TCP/IP interface endpoints.
  • -AddressFamily IPv4 limits the evaluation to IPv4 stacks.
  • -ConnectionState Connected targets only physically or logically connected adapters.
  • InterfaceMetric is the numerical cost assigned to the interface; lower values indicate preferred traffic routing.
  • Dhcp indicates whether IP parameters are assigned dynamically (Enabled) or statically (Disabled).
  • Sort-Object -Property InterfaceMetric sorts the interfaces by route preference.
Consolepowershell
./audit-interfaces.ps1
Outputplaintext
InterfaceAlias              InterfaceIndex InterfaceMetric     Dhcp
--------------              -------------- ---------------     ----
Ethernet0                                8              15  Enabled
Wi-Fi                                    4              25  Enabled
Loopback Pseudo-Interface 1              1              75 Disabled

Platform Availability: Windows PowerShell vs. PowerShell 7 on Linux/macOS

The NetTCPIP module is an operating system-specific module provided by Microsoft for Windows.

  • On Windows: available out-of-the-box on both Windows PowerShell 5.1 and modern PowerShell 7+.
  • On Linux and macOS: the NetTCPIP module is unavailable because non-Windows operating systems lack the underlying Windows CIM provider infrastructure (Root/StandardCimv2).

Practical Usage: Quick Network Health Snapshot

A common first step in troubleshooting is gathering a snapshot of adapter status, IP configuration, and connectivity in one script.

network-snapshot.ps1powershell
Write-Output "=== Network Adapters ==="
Get-NetAdapter |
    Select-Object Name, Status, LinkSpeed |
    Format-Table -AutoSize

Write-Output "`n=== IP Configuration ==="

$config = Get-NetIPConfiguration

foreach ($adapter in $config) {
    Write-Output "Interface: $($adapter.InterfaceAlias)"

    if ($adapter.IPv4Address) {
        Write-Output "IPv4 Address: $($adapter.IPv4Address.IPAddress)"
    }
    else {
        Write-Output "IPv4 Address: None"
    }

    if ($adapter.IPv4DefaultGateway) {
        Write-Output "Default Gateway: $($adapter.IPv4DefaultGateway.NextHop)"
    }
    else {
        Write-Output "Default Gateway: None"
    }

    Write-Output ""
}

Write-Output "=== Connectivity Test ==="
Test-Connection -ComputerName "8.8.8.8" -Count 2 -Quiet

where:

  • Get-NetAdapter lists physical/virtual network interfaces and their link status.
  • Get-NetIPConfiguration summarizes IP settings per adapter.
  • Test-Connection -Quiet returns a simple $true/$false result for connectivity.
Consolepowershell
./network-snapshot.ps1
Outputplaintext
=== Network Adapters ===

Name                         Status       LinkSpeed
----                         ------       ---------
Bluetooth Network Connection Disconnected 3 Mbps
Ethernet0                    Up           1 Gbps



=== IP Configuration ===
Interface: Ethernet0
IPv4 Address: 192.168.178.33
Default Gateway: 192.168.178.1

Interface: Bluetooth Network Connection
IPv4 Address: 169.254.19.170
Default Gateway: None

=== Connectivity Test ===
True
Navigation