Beta 42

Research and Development


PowerShell - Check Active Internet Connection

If your machine has more than one Internet connection (let's say cabled and wireless) at the same time, which connection is used?

Here's a function that determines the active Internet connection:

function test-ipmetric {
      Get-WmiObject Win32_NetworkAdapter -Filter "AdapterType='Ethernet 802.3'" |
      ForEach-Object { $_.GetRelated('Win32_NetworkAdapterConfiguration') } |
      Select-Object Description, Index, IPEnabled, IPConnectionMetric