Created
May 21, 2025 12:58
-
-
Save LikeCarter/ca11acc5742d04f53563ed4229f9a156 to your computer and use it in GitHub Desktop.
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
| $interfaceName = "Wi-Fi" | |
| # Check if the interface is up and connected | |
| $interface = Get-NetAdapter -Name $interfaceName -Physical | Where-Object { $_.Status -eq "Up" } | |
| if ($interface) { | |
| # Check for internet connectivity using Test-NetConnection | |
| $test = Test-NetConnection -ComputerName 8.8.8.8 -InformationLevel Quiet | |
| if (-not $test) { | |
| # Reset DNS servers if no connectivity | |
| Set-DnsClientServerAddress -InterfaceAlias $interfaceName -ResetServerAddresses | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment