Created
June 18, 2021 20:25
-
-
Save foxyseta/cd29ee35fc6177b8d7cc984b51b3b54e to your computer and use it in GitHub Desktop.
A PowerShell script to connect to my home wifi automatically
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
# configure Wi-Fi using dynamic IP (admin required) | |
if (-not (new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)) | |
{ | |
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell"; | |
$newProcess.Arguments = $myInvocation.MyCommand.Definition; | |
$newProcess.Verb = "runas"; | |
[System.Diagnostics.Process]::Start($newProcess); | |
exit | |
} | |
netsh interface ip set address "Wi-Fi" dhcp | |
netsh WLAN add profile "E:\wifi.xml" | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment