Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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

This comment has been minimized.

Copy link

@randomuser1234 randomuser1234 commented Jul 9, 2015

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

This comment has been minimized.

Copy link
Owner Author

@harriha 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