Created
June 5, 2024 21:30
-
-
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 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 -eq "Wi-Fi" -or $_.InterfaceAlias -eq "Ethernet"} | |
# Set a higher metric value for the Ethernet interface | |
foreach ($interface in $interfaces) { | |
if ($interface.InterfaceAlias -eq "Ethernet") { | |
Set-NetIPInterface -InterfaceAlias $interface.InterfaceAlias -InterfaceMetric 100 | |
} else { | |
Set-NetIPInterface -InterfaceAlias $interface.InterfaceAlias -InterfaceMetric 10 | |
} | |
} |
This file contains 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