PowerShell Get-NetIPInterface
last modified February 15, 2025
In this article, we will cover the Get-NetIPInterface
cmdlet in
PowerShell. This cmdlet retrieves information about IP interface configurations.
It helps manage network interfaces and their IP-related properties.
IP Interface basics
An IP interface represents the configuration of a network interface at the
IP layer. It includes properties like interface index, address family, and
DHCP status. The Get-NetIPInterface
cmdlet provides access to
these configurations. It's part of the NetTCPIP module in PowerShell.
Basic Get-NetIPInterface usage
The simplest way to use Get-NetIPInterface
is without parameters.
This lists all IP interfaces on the system. The output includes interface
indexes, addresses, and states. Each interface is represented as an object.
Get-NetIPInterface
This command retrieves all IP interfaces on the system. The output shows interface indexes, address families, and connection states. IPv4 and IPv6 interfaces are both included.
Filter interfaces by address family
You can filter interfaces by their address family using the -AddressFamily parameter. Valid values are IPv4 and IPv6. This helps when you need to work with only one IP version. The filtering occurs at the cmdlet level.
Get-NetIPInterface -AddressFamily IPv4
This command returns only IPv4 interfaces. The output excludes all IPv6 configurations. This is useful when troubleshooting IPv4-specific issues.
PS C:\> .\ipinterface2.ps1 ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore ------- -------------- ------------- ------------ --------------- ---- --------------- ----------- 12 Ethernet IPv4 1500 25 Enabled Connected ActiveStore 1 Loopback Pseudo-Interface 1 IPv4 4294967295 75 Disabled Connected ActiveStore
Get interface by interface index
Interfaces can be retrieved by their unique interface index. This provides precise identification of a specific interface. Use the -InterfaceIndex parameter followed by the index number. Each interface has a unique index.
Get-NetIPInterface -InterfaceIndex 12
This command returns information about the interface with index 12. Only one interface will be returned since indexes are unique. This is useful for scripting when you know the exact interface.
Filter interfaces by connection state
You can filter interfaces based on their connection state. Common states include Connected, Disconnected, and Disabled. This helps identify active network interfaces. Use the -ConnectionState parameter for filtering.
Get-NetIPInterface -ConnectionState Connected
This command lists only interfaces that are currently connected. The output excludes disconnected or disabled interfaces. This is useful for network monitoring scripts.
Get detailed interface information
The default output can be expanded to show all properties. Use the
Format-List
cmdlet with the wildcard character. This reveals
additional details not shown in table view. You can see all configurable
parameters.
Get-NetIPInterface -InterfaceIndex 12 | Format-List *
This command shows all properties of interface 12 in list format. The output includes detailed configuration like router discovery and NLMtu. This helps with advanced network troubleshooting.
Source
In this article, we have covered the Get-NetIPInterface cmdlet in PowerShell.
Author
List all PowerShell tutorials.