Minimal script to remove, add, and connect to a Wi‑Fi profile using netsh
.
- Windows 10/11
- PowerShell 7+ (or Windows PowerShell)
- Run in an elevated console (Run as administrator)
- A valid WLAN profile XML file (e.g.,
A1.xml
)
add-wifi-profile.ps1
: Script to install/connect the profileA1.xml
: Example WLAN profile XML
- Open PowerShell as Administrator in this folder.
- Optionally edit these variables in
add-wifi-profile.ps1
:$SSID_NAME
– target SSID name$PROFILE_XML
– path to the profile XML$IFACE
– Wi‑Fi adapter name (usuallyWi‑Fi
)
- Run:
./add-wifi-profile.ps1
- If you don’t have the XML yet, connect once manually and copy it from:
C:\ProgramData\Microsoft\Wlansvc\Profiles\Interfaces\...
- The script removes any existing profile with the same name, adds the XML, verifies, then connects and disconnects after ~20 seconds. To stay connected, comment out the small disconnect block (the
Start-Sleep
andnetsh wlan disconnect
lines) in the script. - For a non-hashed (plain-text) key in the XML, set
<protected>false</protected>
.