forked from RReverser/WiFi-Password
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWiFi-Password.psm1
53 lines (49 loc) · 1.29 KB
/
WiFi-Password.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function Extract-Value(
[string[]]$Lines,
[string]$Name
) {
$Lines | Select-String " $Name\s+: (.*)" |% { $_.Matches.Groups[1].Value }
}
<#
.Synopsis
Get list of Wi-Fi networks.
.Description
Returns SSIDs of all the stored Wi-Fi networks.
.Example
List-WiFi
#>
function Select-WiFi {
netsh wlan show profiles | Select-String ": (.*)" |% { $_.Matches.Groups[1].Value }
}
<#
.Synopsis
View password of current or given Wi-Fi network.
.Description
Allows to view stored password of currently or earlier connected Wi-Fi network.
.Parameter SSID
Name of stored Wi-Fi network.
.Example
# View password of currently connected Wi-Fi network.
Show-WiFiPassword
.Example
# View stored password of earlier connected Wi-Fi network.
Show-WiFiPassword Home
#>
function Show-WiFiPassword(
[string]$SSID = (Extract-Value (netsh wlan show interface) "SSID")
) {
$Network = netsh wlan show profiles name=$SSID key=clear
If (!$?) {
Write-Host $Network
Return
}
$AuthType = Extract-Value $Network "Authentication"
$Password = Extract-Value $Network "Key Content"
Write-Host "
SSID : $SSID
Password : $Password
Auth type : $AuthType
"
}
Set-Alias WiFi-Password Show-WiFiPassword
Export-ModuleMember -Function *WiFi* -Alias *WiFi*