netsh wlan
netsh wlan is the command-line interface of the Windows WLAN AutoConfig service: it shows what your Wi-Fi driver supports, connects to networks, and adds, exports, filters and edits saved profiles. It is built into Windows (CMD and PowerShell); some commands need an admin prompt, and on Linux iw and nmcli do the same job.
177.1 How it works
- Step 1
1.netsh wlan talks only to the WLAN AutoConfig service, which does the real Wi-Fi work
- Step 2
2.1 Scan: AP (SSID HomeWiFi) broadcasts beacons -> show networks
- Step 3
3.2 Profile: a saved profile (SSID, security, key) is picked -> show profiles
- Step 4
4.3 Connect: association request + WPA2 4-way handshake -> connect name=...
- Step 5
5.4 IP: DHCP to router 192.168.1.1 -> show interfaces: State connected
177.2 Context commands
netsh wlan ?Commands in this context:? - Displays a list of commands.add - Adds a configuration entry to a table.connect - Connects to a wireless network.delete - Deletes a configuration entry from a table.disconnect - Disconnects from a wireless network.dump - Displays a configuration script.export - Saves WLAN profiles to XML files.help - Displays a list of commands.IHV - Commands for IHV logging.refresh - Refresh hosted network settings.reportissues - Generate WLAN smart trace report.set - Sets configuration information.show - Displays information.start - Start hosted network.stop - Stop hosted network.- ? or help after any command gives its help; dump prints a config script; reportissues (admin) builds a WLAN smart trace report.
- Lab: office Windows 11 (netsh 10.0.26100), non-elevated; only help and safe show commands were run because others expose SSIDs and MACs.
177.3 show: information commands
| Command | Shows |
|---|---|
| show interfaces | State, SSID, signal, channel, receive rate |
| show networks [mode=bssid] | Visible SSIDs; with bssid: each AP's signal and channel |
| show profiles [name=X key=clear] | Saved profiles; key=clear (admin) shows the password |
| show drivers | Radio types, auth/cipher support, hosted network |
| show settings | Global WLAN settings |
| show filters [permission=allow|block] | Allowed and blocked lists |
| show wirelesscapabilities | Support for Wi-Fi 6, WPA3 etc. |
| show wlanreport [duration=7] | HTML report of recent sessions (admin), default 3 days |
| show onlyUseGPProfilesforAllowedNetworks | Whether only Group Policy profiles are used on GP networks |
netsh wlan show driversnetsh wlan show settings Type : Native Wi-Fi Driver Radio types supported : 802.11n 802.11g 802.11b FIPS 140 mode supported : Yes 802.11w Management Frame Protection supported : Yes Hosted network supported : No Authentication and cipher supported in infrastructure mode: Open None WPA2-Personal CCMP WPA-Enterprise TKIP WPA2-Enterprise CCMPWireless LAN settings Show blocked networks in visible network list: No Only use GP profiles on GP-configured networks: No Hosted network mode allowed in WLAN service: Yes Allow shared user credentials for network authentication: Yes Block period: Not Configured. Auto configuration logic is enabled on interface "Wi-Fi" MAC randomization not available on interface Wi-Fi- Radio types stop at 802.11n: this card is Wi-Fi 4 only, and there is no WPA3 in the cipher list.
- Show commands never change anything; if company Wi-Fi does not connect, check onlyUseGPProfiles (hand-made profiles are ignored on GP networks when on).
177.4 connect and disconnect
netsh wlan connect name=CorpWiFi interface="Wi-Fi"netsh wlan disconnect interface="Wi-Fi"- connect always uses a saved profile: name= is required.
- ssid= is needed only if the profile holds several SSIDs; interface= only with two or more Wi-Fi interfaces (no wildcard).
- disconnect interface= disconnects that interface; a wildcard is allowed here.
177.5 Profiles: XML, add, delete, export
<WLANProfile xmlns="https://www.microsoft.com/networking/WLAN/profile/v1"> <name>SampleWPA2PSK</name> <SSIDConfig> <SSID> <name>SampleWPA2PSK</name> </SSID> </SSIDConfig> <connectionType>ESS</connectionType> <connectionMode>auto</connectionMode> <autoSwitch>false</autoSwitch> ... <authentication>WPA2PSK</authentication> <encryption>AES</encryption> <useOneX>false</useOneX></WLANProfile>| Command | Meaning |
|---|---|
| add profile filename=X.xml | Import an XML profile |
| interface="Wi-Fi" | Only on that interface (else all) |
| user=all | user=current | All users (default) / only you |
| delete profile name=X | Forget a saved network |
| delete profile name=* i=* | Deletes every profile: careful! |
| export profile [name=] folder= [key=clear] | Save profiles as XML (all if no name); key=clear (admin) writes the password in plain text |
| export hostednetworkprofile | Export the hosted network profile |
netsh wlan export profile name="CorpWiFi" folder="C:\WiFiProfiles" key=clear- Exported files are named after the interface and profile; folder must be an existing local folder (no UNC path).
177.6 Filters: allowed and blocked networks
- Step 1
1.add filter permission=allow ssid=MyNetwork networktype=infrastructure
- Step 2
2.add filter permission=denyall networktype=infrastructure
- Step 3
3.Laptop connects to MyNetwork (allowed list)
- Step 4
4.Neighbour Wi-Fi disappears from the list and cannot be joined
- Step 5
5.show filters lists Allowed: MyNetwork, Denied: denyall
Docs examples; need an admin prompt
- allow and block need ssid=; denyall has no ssid and blocks everything else of that type.
- networktype=infrastructure = AP networks, adhoc = device-to-device (IBSS).
- delete filter with the same parameters removes the entry.
177.7 set: global and interface settings
| set ... | Effect |
|---|---|
| autoconfig enabled=no | Stop auto-connect and background scans on that interface |
| blockednetworks display=show|hide | Show/hide blocked networks in the list |
| blockperiod value=0-60 | Minutes to hold back auto-connect to a failed network |
| profileorder name= interface= priority=1 | Move a profile to the top (all three required) |
| profiletype profiletype=all|current | All-user or per-user profile |
| randomization enabled=yes|no | Random MAC on/off |
| tracing mode=yes|no|persistent | WLAN tracing (persistent survives reboot) |
| allowexplicitcreds / createalluserprofile | Shared creds / who may create all-user profiles |
177.8 set profileparameter: edit a saved profile
netsh wlan set profileparameter name="CorpWiFi" interface="Wi-Fi" SSIDname="CorpWiFi_5G" ConnectionMode=auto| Group | Parameters | Use |
|---|---|---|
| Connection | SSIDname, ConnectionType=ESS|IBSS, ConnectionMode=auto|manual, autoSwitch, nonBroadcast | manual = never auto-join (public networks); nonBroadcast = hidden SSID |
| Privacy | Randomization=yes|no|daily | daily = new random MAC every day |
| Security | authentication=open|shared|WPA|WPA2|WPAPSK|WPA2PSK, encryption=none|WEP|TKIP|AES, keyType, keyMaterial, keyIndex | Change security type or password |
| 802.1X | useOneX, authMode=machineOrUser|machineOnly|userOnly|guest, ssoMode, maxDelay, allowDialog, userVLAN | Enterprise login |
| Roaming | PMKCacheMode/Size/TTL, preAuthMode, preAuthThrottle | Fast roaming (WPA2) |
| Timers | heldPeriod, AuthPeriod, StartPeriod (1-3600 s), maxStart, maxAuthFailures, cacheUserData | 802.1X login behaviour |
| Cost | cost=default|unrestricted|fixed|variable | fixed/variable = metered (phone hotspot) |
- name= is required plus at least one more parameter; no XML export needed.
177.9 Hosted network and IHV logging
netsh wlan set hostednetwork [mode=]allow|disallow [ssid=]<ssid> [key=]<passphrase> [keyUsage=]persistent|temporarynetsh wlan start hostednetworknetsh wlan stop hostednetworknetsh wlan refresh hostednetwork [data=]keyC:\> netsh wlan show drivers Hosted network supported : NoC:\> netsh wlan show settings Hosted network mode allowed in WLAN service: Yes- Hosted network = laptop as a software AP (SoftAP); keyUsage persistent keeps the key, temporary deletes it on stop; refresh sets a new key.
- It is legacy: this driver says Hosted network supported: No; Windows now uses Mobile Hotspot.
- netsh wlan IHV startlogging / stoplogging: verbose driver logs for the Independent Hardware Vendor (card maker).
177.10 Common mistakes
- Reading Receive rate in show interfaces as internet speed: it is only the Wi-Fi link rate (300 Mbps link, 50 Mbps internet plan).
- Leaving exported XML files with key=clear lying around: they contain the password in plain text.
- Running delete profile name=* i=* by mistake.
- Deleting a profile just to stop auto-connect, instead of ConnectionMode=manual.
177.11 Interview tips
- Migrate profiles: export profile folder= key=clear (admin), add profile filename= user=all on the new laptop, then delete the XML files.
- Stop auto-connect but keep the profile: set profileparameter name=X ConnectionMode=manual.
- Lock a laptop to one network: add filter allow ssid=X, then add filter denyall.
- Check card capability (Wi-Fi 4/5/6, WPA3) with show drivers / show wirelesscapabilities.