Last active
October 13, 2024 10:32
-
-
Save elico/b1b21ce1d5a255182e70dbb9c13b2967 to your computer and use it in GitHub Desktop.
Powershell Scripts to change the interfaces preference to WIFI and another to reset which will probably prefer the ethernet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the network interfaces | |
$interfaces = Get-NetIPInterface | Where-Object {$_.InterfaceAlias -match "Wi-Fi" -or $_.InterfaceAlias -match "vEthernet" -or $_.InterfaceAlias -match "Ethernet"} | |
# Set a higher metric value for the Ethernet interface | |
foreach ($interface in $interfaces) { | |
Write-Host $interface.InterfaceAlias | |
if ($interface.InterfaceAlias -match "Ethernet") { | |
Write-Host "Ethernet Interface" | |
Set-NetIPInterface -InterfaceAlias $interface.InterfaceAlias -InterfaceMetric 100 | |
} | |
if ($interface.InterfaceAlias -match "vEthernet") { | |
Write-Host "Virtual Ethernet Interface" | |
Set-NetIPInterface -InterfaceAlias $interface.InterfaceAlias -InterfaceMetric 100 | |
} | |
if ($interface.InterfaceAlias -match "Wi-Fi") { | |
Write-Host "Wifi Interface" | |
Set-NetIPInterface -InterfaceAlias $interface.InterfaceAlias -InterfaceMetric 10 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get all network interfaces | |
$interfaces = Get-NetIPInterface | |
# Reset interface metrics to default values | |
foreach ($interface in $interfaces) { | |
Set-NetIPInterface -InterfaceAlias $interface.InterfaceAlias -AutomaticMetric enabled | |
} | |
Write-Host "Network interface preferences reset to default." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment