Skip to content

Instantly share code, notes, and snippets.

@foxyseta
Created June 18, 2021 20:25
Show Gist options
  • Save foxyseta/cd29ee35fc6177b8d7cc984b51b3b54e to your computer and use it in GitHub Desktop.
Save foxyseta/cd29ee35fc6177b8d7cc984b51b3b54e to your computer and use it in GitHub Desktop.
A PowerShell script to connect to my home wifi automatically
# 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