https://www.sikich.com

Understanding the PowerShell Command Get-NetIPInterface and the Impact of Changing the InterfaceMetric Value

INSIGHT 4 min read

WRITTEN BY

Craig Schellenberg

In the world of network management, efficiency and precision are key. One of the tools that network administrators often rely on is PowerShell, a powerful scripting language that allows for automation and management of various tasks. Among the many commands available in PowerShell, Get-NetIPInterface stands out as a crucial one for managing network interfaces. In this blog, we will delve into the details of this command and explore the significance of changing the InterfaceMetric value, both through the Command Line Interface (CLI) and the Graphical User Interface (GUI) network adapter properties.

What is Get-NetIPInterface?

The Get-NetIPInterface command in PowerShell is used to retrieve information about the IP interfaces on a system. This command provides a wealth of information, including the interface index, interface alias, address family, and the InterfaceMetric value. The InterfaceMetric is particularly important as it determines the priority of the interface when multiple routes are available.

The Role of InterfaceMetric

The InterfaceMetric value is a numerical value that influences the selection of the network interface for outbound traffic. When multiple network interfaces are available, the one with the lowest InterfaceMetric value is preferred. This is crucial in scenarios where a system is connected to multiple networks, such as a wired and a wireless network. By adjusting the InterfaceMetric value, administrators can control which interface is used for specific types of traffic, thereby optimizing network performance and reliability.

Changing the InterfaceMetric Value Using CLI

To change the InterfaceMetric value using PowerShell, you can use the Set-NetIPInterface command. Here’s a step-by-step guide:

  1. Retrieve Current Interface Information: First, use the Get-NetIPInterface command to list all network interfaces and their current metrics.
  2. Get-NetIPInterface
  3. Identify the Interface: Identify the interface you want to modify by noting its InterfaceIndex or InterfaceAlias.
  4. Set the New Metric: Use the Set-NetIPInterface command to change the InterfaceMetric value. For example, to set the metric of an interface with InterfaceIndex 12 to 10, you would use:
  5. Set-NetIPInterface -InterfaceIndex 12 -InterfaceMetric 10
  6. Verify the Change: Finally, verify that the change has been applied by running the Get-NetIPInterface command again.
  7. Get-NetIPInterface

Changing the InterfaceMetric Value Using GUI

For those who prefer a graphical approach, the InterfaceMetric value can also be changed through the network adapter properties in Windows. Here’s how:

  1. Open Network Connections: Navigate to the Network Connections window. You can do this by typing ncpa.cpl in the Run dialog (Win + R).
  2. Select the Network Adapter: Right-click on the network adapter you want to modify and select Properties.
  3. Access TCP/IPv4 Properties: In the adapter properties window, select Internet Protocol Version 4 (TCP/IPv4) and click on Properties.
  4. Advanced Settings: In the TCP/IPv4 properties window, click on the Advanced button.
  5. Set the Interface Metric: In the Advanced TCP/IP Settings window, you will see a field for Interface Metric. Enter the desired value and click OK to apply the changes.
  6. Verify the Change: You can verify the change by using the Get-NetIPInterface command in PowerShell to ensure the new metric is reflected.

Practical Applications

Changing the InterfaceMetric value can have several practical applications. For instance, in a corporate environment where both wired and wireless connections are available, setting a lower metric for the wired connection ensures that it is preferred for critical business applications, providing better performance and stability. Conversely, in a home network, you might prioritize a wireless connection for convenience.

Another scenario involves VPN connections. By adjusting the InterfaceMetric value, you can ensure that traffic destined for specific networks is routed through the VPN, while other traffic uses the regular internet connection. This can enhance security and ensure compliance with organizational policies.

Conclusion

The Get-NetIPInterface command and the ability to change the InterfaceMetric value are powerful tools in the arsenal of a network administrator. Whether you prefer the precision of the CLI or the simplicity of the GUI, understanding how to manipulate these settings can lead to more efficient and reliable network management. By prioritizing the right network interfaces for different types of traffic, you can optimize performance, enhance security, and ensure a seamless user experience.

Have any questions about the Get-NetIPInterace command or any other PowerShell commands? Please reach out to our experts at any time!

Author

Craig Schellenberg is a Senior Network Consultant at Sikich that works with businesses to improve their IT. Being detail oriented assists in his ability to design and deploy new solutions as well as troubleshoot complex issues. His primary areas of focus are virtualization and storage on premise (whether through VMware vSphere or Microsoft Hyper-V), Microsoft Cloud services such as Azure and Office 365, Microsoft SQL design and administration, backup/DR/Business Continuance, and network route/switch/firewalls.

Craig holds many certifications including his MCSE (Microsoft Certified Solutions Expert) in Productivity, Messaging, and Cloud Platform and Infrastructure. Craig also holds multiple certifications of his VCP (VMware Certified Professional) including version 3, 4 (Data Center Virtualization), 5 (Data Center Virtualization), 5 (Desktop), Cloud, and 6 (Data Center Virtualization).