Skip to content

Instantly share code, notes, and snippets.

@elico
Created June 5, 2024 21:30
Show Gist options
  • Save elico/b1b21ce1d5a255182e70dbb9c13b2967 to your computer and use it in GitHub Desktop.
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
# 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
}
}
# 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