Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I identify the network adapter (or interface) name used for a successful ping in a window bat or powershell

Is there a way to identify the network adapter (or interface) name used for a successful ping

eg I have the following adapters:
Network Adapters

I perform the command

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ping google.com

which is successful, I would like to know that the adapter used is either "Wi-Fi" Sunrise_5GHz_387918

There is a similar question for c#
Identifying active network interface

But I am looking for a windows batch file way (possibly powershell).

>Solution :

You can do that in PS using:

get-wmiobject win32_networkadapter | select netconnectionid, name, InterfaceIndex, netconnectionstatus

OR,
You can use netsh

netsh interface ipv4 show interfaces

In the newer version of PS like in windows 8, you can even directly use:

Get-NetAdapter | SELECT name, status, speed, fullduplex | where status -eq 'up'

Note by that the netconnectionstatus value indicates the connection status. 2 indicates connected

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading