Lets assume, that I have a host with 2 ethernet cards. One connected to internal network (without internet access), and another to different network with internet access.
In Linux I have a command, to deternine, which adapter used to connect to the internet:
vasyl@retail-z3-1:~$ ip route get 8.8.8.8
8.8.8.8 via 10.186.0.1 dev ens4 src 1.1.1.1
So, I know, that ens4 has internet connectivity.
Is there any way to determine which adapter name used for internet connectivity in PowerShell?
PS I have a following code to get all connected adapters - how to determine adapter, used for internet connectivity?
$adapters = Get-NetAdapter
foreach ($adapter in $adapters){
if($adapter.Status -eq "Up" -and $adapter.Name.Contains("Ethernet")){
Write-Host $adapter.MacAddress
}
}