Skip to content

Instantly share code, notes, and snippets.

@harriha
Last active September 12, 2015 19:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harriha/11332150 to your computer and use it in GitHub Desktop.
Save harriha/11332150 to your computer and use it in GitHub Desktop.
[Windows 8] Show passwords of Wi-Fi profiles in clear-text
(netsh wlan show profiles) | # Fetch all Wi-Fi profiles
Select-String "\:(.+)$" | # Grab the profile name (note: not necessarily equal to SSID)
%{$name=$_.Matches.Groups[1].Value.Trim(); $_} | # Store profile name to a var
%{(netsh wlan show profile name="$name" key=clear)} | # Fetch profile details with clear-text password
Select-String "Key Content\W+\:(.+)$" | # Grab the password
%{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | # Store password to a var
%{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | # Construct an object to be able to use Format-Table
Format-Table -AutoSize # Format the output
Write-Host ""
Write-Host "Press any key to continue..."
Read-Host
@randomuser1234
Copy link

Is this Windows 8 only? I get an error sometimes on various computers that are Windows 7.

Cannot index into a null array.
At F:\show-wifi-passwords.ps1.ps1:66 char:82

  • (netsh wlan show profiles) | Select-String ":(.+)$" | %{$name=$.Matches.Groups[ <<<< 1].Value.Trim();$} |
    %{(netsh wlan show profile name="$name" key=clear)} | Select-String "Key Content\W+:(.+)$" | %{$pass=$.Matches.Groups[1].Value.Trim(); $} | %{
    [PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} -erroraction Continue | Format-Table -AutoSize
    • CategoryInfo : InvalidOperation: (1:Int32) [], RuntimeException
    • FullyQualifiedErrorId : NullArray

@harriha
Copy link
Author

harriha commented Sep 12, 2015

@randomuser1234 Yeah, this was crafted on Windows 8 and haven't tested it on Windows 7 at all. My guess is that some underlying APIs or PowerShell versions are slightly different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment