none
Foreach question RRS feed

  • Question

  • Trying to list the current adapter that is being used in the test; here's the script:

    $IPconnections = (Get-NetAdapter -physical | where status -eq 'up').Name

    foreach ($IPconnection in $IPconnections) {
    ping 8.8.8.8
    Tracert "Google.com"
    }

    I'm not able to get it to list the current adapter it is using in the loop....


    Jason Ostrowski

    • Moved by Bill_Stewart Wednesday, September 4, 2019 6:29 PM This is not "fix/debug/rewrite script for me" forum
    Monday, March 11, 2019 2:49 PM

All replies

  • You will have to write a loop that outputs what you want.  If you search you will find hundreds of examples on how to do this.

    You should also use Test-Connection for pinging and not the old ping utility.


    \_(ツ)_/

    Monday, March 11, 2019 2:54 PM
  • Not sure if it is a Windows issue but no matter what I try it always tests the Ethernet.. I am connected to both Ethernet and WIFI and even if I specify WIFI it runs test on Ethernet...

    Jason Ostrowski

    Monday, March 11, 2019 4:53 PM
  • Any kind of ping will always route through the primary adapter.  You network setup and the visibility of the DNS servers will determine the adapter path when there are multiple adapters.

    This has nothing to do with scripting. It is how networks work.


    \_(ツ)_/

    Monday, March 11, 2019 5:42 PM