/build/static/layout/Breadcrumb_cap_w.png

How to prioritise the wired NIC over the wirelesses ones using PowerShell

If you have more than one network card active at the same time which one will take the priority over the others?

Sometimes may happen that you have your laptop connected to the wired network and the wireless one at the same time and the wireless NIC take the presence.

When this happens you are not enjoying the fastest possible connection to your resources.

How the priority is really assigned initially by the OS to the NICs is not really clear to me but everything is decided by the value of the parameter IPConnectionMetric .

To have a look at the current settings for this value in your system you can run this PowerShell script:

Get-WmiObject-ClassWin32_NetworkAdapter-Filter"AdapterType='Ethernet 802.3'"|

foreach {

 Get-WmiObject-ClassWin32_NetworkAdapterConfiguration-Filter"Index=$($_.DeviceId) AND IPEnabled = True"  |

 selectDescription,IPConnectionMetric,IPAddress|ft-AutoSize

}

Bigger the value of IPConnectionMetric lower is the priority for this NIC

If you want to amend the value for all the Wireless adapters and make the other (wired) adapters to have precedence over the Wireless adapter you can run the following script:

It will set the IPConnectionMetric of the wireless cards to 900. A reboot will be necessary to enforce the setting.

 

Get-WmiObject-ClassWin32_NetworkAdapter-Filter"AdapterType='Ethernet 802.3' AND NetConnectionID like '%Wireless%'"|
foreach {
        Get-WmiObject-ClassWin32_NetworkAdapterConfiguration-Filter"Index=$($_.DeviceId) AND IPEnabled = True"  |
        Invoke-WmiMethod-NameSetIPConnectionMetric-ArgumentList 900
 }    

 


Comments

  • Hey, your Powershell script to determine the prioritys got a bit scrambled up. I figured it out though:
    <code>
    Get-WmiObject -Class Win32_NetworkAdapter -Filter "AdapterType='Ethernet 802.3'" | foreach { Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "Index=$($_.DeviceId) AND IPEnabled = True"|select Description,IPConnectionMetric,IPAddress|ft -AutoSize}
    </code>
    Keep up the good work! - ChristianT 10 years ago
    • hello! I know..I tried to edit the article many times but I'm not able to fix it.
      Regards,
      Marco - StockTrader 10 years ago
This post is locked

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ