netsh - View and Change Network Settings
netsh (Network Shell) is a command for viewing and changing Windows network settings from the command line. It handles Wi-Fi connection data, IP address and DNS settings, the firewall, and more.
While ipconfig mostly shows the current state, netsh can also change settings.
Basic Syntax of the netsh Command
netsh [context] [subcontext] <command> [options]
The depth of contexts varies by command (winsock reset has one level, interface ip show config has two).
netsh uses a “context” for each area you want to work with. Common ones are:
| Context | Target |
|---|---|
wlan | Wireless LAN (Wi-Fi) |
interface | IP settings of network adapters |
advfirewall | Microsoft Defender Firewall |
winsock | Winsock catalog |
If you get lost, type part of a command followed by ? to list the commands available at that level.
netsh wlan ?
List Saved Wi-Fi Networks
netsh wlan show profiles
The output text depends on the Windows display language.
Show a Saved Wi-Fi Password
Specify the profile name with name= and add key=clear.
netsh wlan show profile name="home-wifi" key=clear
The password appears as “Key Content” under “Security settings”.
Depending on the saved profile, “Key Content” may not appear unless you run as administrator. The password is displayed on screen, so make sure it does not show up in screenshots or screen sharing. Use this only to check passwords on your own device.
Show IP Address Settings
netsh interface ip show config
For each adapter, it shows the IP address, subnet mask, default gateway, and DNS servers.
To list adapter names:
netsh interface show interface
Set an IP Address and DNS
These examples assume the adapter is named Wi-Fi. Changing settings requires administrator rights.
netsh interface ip set address name="Wi-Fi" static 192.168.1.50 255.255.255.0 192.168.1.1
netsh interface ip set dnsservers name="Wi-Fi" static 8.8.8.8
netsh interface ip set address name="Wi-Fi" dhcp
netsh interface ip set dnsservers name="Wi-Fi" dhcp
An incorrect IP address or gateway can leave you unable to connect. Use the adapter name exactly as shown by netsh interface show interface. Note the original values with netsh interface ip show config first, and use the DHCP commands above to recover.
Reset Winsock
When your connection is unstable, one remedy is to reset the Winsock catalog to its default state.
netsh winsock reset
This requires administrator rights, and you must restart the PC afterward. It may also affect VPN and security software settings. If other causes are possible, first clear the DNS cache with ipconfig /flushdns or check connectivity with ping.
Create a Wi-Fi Diagnostic Report
netsh wlan show wlanreport
Administrator rights are required. This creates an HTML report summarizing the past few days of Wi-Fi connection history, errors, and causes of disconnections. The default output path is C:\ProgramData\Microsoft\Windows\WlanReport\wlan-report-latest.html.
Use It in a Batch File
@echo off
set /p WIFI_NAME=Enter the Wi-Fi profile name:
netsh wlan show profile name="%WIFI_NAME%" key=clear | findstr /i /c:"Key Content"
pause
findstr narrows the output to the line containing the key. The label is localized, so adjust the search word to match your display language.
Summary
| Goal | Command |
|---|---|
| List saved Wi-Fi networks | netsh wlan show profiles |
| Show a Wi-Fi password | netsh wlan show profile name="Name" key=clear |
| Show IP settings | netsh interface ip show config |
| Return to DHCP | netsh interface ip set address name="Name" dhcp |
| Reset Winsock | netsh winsock reset |
| Wi-Fi diagnostic report | netsh wlan show wlanreport |