A simple one-line script that retrieves all stored WiFi network names and their passwords from a Windows system.
for /f "tokens=2 delims=:" %i in ('netsh wlan show profiles^|findstr "All User Profile"') do @for /f "tokens=* delims= " %j in ("%i") do @(echo. & echo %j & for /f "tokens=2 delims=:" %k in ('netsh wlan show profile name^="%j" key^=clear^|findstr /C:"Key Content"') do @for /f "tokens=* delims= " %l in ("%k") do @echo %l)
(netsh wlan show profiles) -match 'All User Profile' | ForEach-Object { $name = $_ -replace '.*:\s+'; Write-Host "`n$name" -F Cyan; $key = netsh wlan show profile name="$name" key=clear | Select-String 'Key Content' -EA 0; if ($key) { $key.ToString() -replace '.*:\s+','' } else { Write-Host "none" -F DarkGray } }
netsh.exe wlan show profiles | grep "All User Profile" | sed -E 's/.*:\s*//' | while read -r n; do echo -e "\033[36m\n$n\033[0m"; k=$(netsh.exe wlan show profile name="$n" key=clear | grep "Key Content" 2>/dev/null | sed -E 's/.*:\s*//'); if [ -n "$k" ]; then echo "$k"; else echo -e "\033[90mnone\033[0m"; fi; done
- Lists all WiFi profiles using
netsh wlan show profiles
- Filters to get just the network names
- For each network name:
- Displays the network name in cyan
- Retrieves the password using
netsh wlan show profile name="network" key=clear
- Extracts and displays the password, or shows
none
if no password is stored
NetworkName1
password123
NetworkName2
none
NetworkName3
securepassword
- This script only works for retrieving passwords of networks that the current user has already connected to and saved on the local machine.
- Administrator privileges may be required to view all passwords.
- This tool is provided for educational purposes and personal network management only.
- Always respect privacy and only use on networks you own or have explicit permission to manage.
here's what it looks like: