├── LICENSE ├── README.md └── WiFi-Password.psm1 /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ingvar Stepanyan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WiFi-Password 2 | 3 | People ask you for the Wi-Fi password. Answer quickly. **Windows only**. 4 | 5 | ![Screenshot](https://cloud.githubusercontent.com/assets/557590/6204307/05ab9f88-b54f-11e4-9293-b2bd8c20a409.png) 6 | 7 | This is inspired by [same-purpose tool for macOS](https://github.com/rauchg/wifi-password) by [@rauchg](https://github.com/rauchg). 8 | 9 | ## How to use 10 | 11 | **1. Install it** 12 | 13 | First of all, install [PsGet](http://psget.net/) if you don't have it yet - it's awesome module manager for PowerShell: 14 | 15 | ```powershell 16 | (new-object Net.WebClient).DownloadString("https://raw.githubusercontent.com/psget/psget/master/GetPsGet.ps1") | iex 17 | ``` 18 | 19 | Now, you can easily install module itself: 20 | 21 | ```powershell 22 | Install-Module WiFi-Password 23 | ``` 24 | 25 | **2. Use it:** 26 | 27 | To get the password for the WiFi you're currently logged onto: 28 | 29 | ```powershell 30 | Show-WiFiPassword 31 | ``` 32 | 33 | or just 34 | 35 | ```powershell 36 | wifi-password 37 | ``` 38 | 39 | To get it for a specific SSID: 40 | 41 | ```powershell 42 | $ wifi-password 43 | ``` 44 | 45 | To list all the stored WiFi networks: 46 | 47 | ```powershell 48 | Select-WiFi 49 | ``` 50 | 51 | ## License 52 | 53 | MIT 54 | -------------------------------------------------------------------------------- /WiFi-Password.psm1: -------------------------------------------------------------------------------- 1 | function Extract-Value( 2 | [string[]]$Lines, 3 | [string]$Name 4 | ) { 5 | $Lines | Select-String " $Name\s+: (.*)" |% { $_.Matches.Groups[1].Value } 6 | } 7 | 8 | <# 9 | .Synopsis 10 | Get list of Wi-Fi networks. 11 | .Description 12 | Returns SSIDs of all the stored Wi-Fi networks. 13 | .Example 14 | List-WiFi 15 | #> 16 | function Select-WiFi { 17 | netsh wlan show profiles | Select-String ": (.*)" |% { $_.Matches.Groups[1].Value } 18 | } 19 | 20 | <# 21 | .Synopsis 22 | View password of current or given Wi-Fi network. 23 | .Description 24 | Allows to view stored password of currently or earlier connected Wi-Fi network. 25 | .Parameter SSID 26 | Name of stored Wi-Fi network. 27 | .Example 28 | # View password of currently connected Wi-Fi network. 29 | Show-WiFiPassword 30 | .Example 31 | # View stored password of earlier connected Wi-Fi network. 32 | Show-WiFiPassword Home 33 | #> 34 | function Show-WiFiPassword( 35 | [string]$SSID = (Extract-Value (netsh wlan show interface) "SSID") 36 | ) { 37 | $Network = netsh wlan show profiles name=$SSID key=clear 38 | If (!$?) { 39 | Write-Host $Network 40 | Return 41 | } 42 | $AuthType = Extract-Value $Network "Authentication" 43 | $Password = Extract-Value $Network "Key Content" 44 | Write-Host " 45 | SSID : $SSID 46 | Password : $Password 47 | Auth type : $AuthType 48 | " 49 | } 50 | 51 | Set-Alias WiFi-Password Show-WiFiPassword 52 | 53 | Export-ModuleMember -Function *WiFi* -Alias *WiFi* 54 | --------------------------------------------------------------------------------