SkillPilotAI

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

Wi-Fi connection stages and netsh wlan
  1. 1.netsh wlan talks only to the WLAN AutoConfig service, which does the real Wi-Fi work

  2. 2.1 Scan: AP (SSID HomeWiFi) broadcasts beacons -> show networks

  3. 3.2 Profile: a saved profile (SSID, security, key) is picked -> show profiles

  4. 4.3 Connect: association request + WPA2 4-way handshake -> connect name=...

  5. 5.4 IP: DHCP to router 192.168.1.1 -> show interfaces: State connected

177.2 Context commands

Terminal
netsh wlan ?
Output
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

CommandShows
show interfacesState, 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 driversRadio types, auth/cipher support, hosted network
show settingsGlobal WLAN settings
show filters [permission=allow|block]Allowed and blocked lists
show wirelesscapabilitiesSupport for Wi-Fi 6, WPA3 etc.
show wlanreport [duration=7]HTML report of recent sessions (admin), default 3 days
show onlyUseGPProfilesforAllowedNetworksWhether only Group Policy profiles are used on GP networks
Terminal
netsh wlan show driversnetsh wlan show settings
Output
    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

Terminal
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

HTML
<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>
CommandMeaning
add profile filename=X.xmlImport an XML profile
interface="Wi-Fi"Only on that interface (else all)
user=all | user=currentAll users (default) / only you
delete profile name=XForget 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 hostednetworkprofileExport the hosted network profile
Terminal
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

Allow only MyNetwork
  1. 1.add filter permission=allow ssid=MyNetwork networktype=infrastructure

  2. 2.add filter permission=denyall networktype=infrastructure

  3. 3.Laptop connects to MyNetwork (allowed list)

  4. 4.Neighbour Wi-Fi disappears from the list and cannot be joined

  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=noStop auto-connect and background scans on that interface
blockednetworks display=show|hideShow/hide blocked networks in the list
blockperiod value=0-60Minutes to hold back auto-connect to a failed network
profileorder name= interface= priority=1Move a profile to the top (all three required)
profiletype profiletype=all|currentAll-user or per-user profile
randomization enabled=yes|noRandom MAC on/off
tracing mode=yes|no|persistentWLAN tracing (persistent survives reboot)
allowexplicitcreds / createalluserprofileShared creds / who may create all-user profiles

177.8 set profileparameter: edit a saved profile

Terminal
netsh wlan set profileparameter    name="CorpWiFi" interface="Wi-Fi"    SSIDname="CorpWiFi_5G" ConnectionMode=auto
GroupParametersUse
ConnectionSSIDname, ConnectionType=ESS|IBSS, ConnectionMode=auto|manual, autoSwitch, nonBroadcastmanual = never auto-join (public networks); nonBroadcast = hidden SSID
PrivacyRandomization=yes|no|dailydaily = new random MAC every day
Securityauthentication=open|shared|WPA|WPA2|WPAPSK|WPA2PSK, encryption=none|WEP|TKIP|AES, keyType, keyMaterial, keyIndexChange security type or password
802.1XuseOneX, authMode=machineOrUser|machineOnly|userOnly|guest, ssoMode, maxDelay, allowDialog, userVLANEnterprise login
RoamingPMKCacheMode/Size/TTL, preAuthMode, preAuthThrottleFast roaming (WPA2)
TimersheldPeriod, AuthPeriod, StartPeriod (1-3600 s), maxStart, maxAuthFailures, cacheUserData802.1X login behaviour
Costcost=default|unrestricted|fixed|variablefixed/variable = metered (phone hotspot)
  • name= is required plus at least one more parameter; no XML export needed.

177.9 Hosted network and IHV logging

Terminal
netsh wlan set hostednetwork    [mode=]allow|disallow [ssid=]<ssid>    [key=]<passphrase>    [keyUsage=]persistent|temporarynetsh wlan start hostednetworknetsh wlan stop hostednetworknetsh wlan refresh hostednetwork [data=]key
Output
C:\> 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.