Skip to content

Commit 374b5f0

Browse files
Merge pull request #249 from silversword411/main
chore: Refactor Win_Wifi_SSID_and_Password_Retrieval.ps1 to add autoc…
2 parents f19c419 + 9e193e8 commit 374b5f0

2 files changed

Lines changed: 30 additions & 10 deletions

File tree

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1-
# Query Windows 10 Saved SSID details outputs the WIFI name and password.
2-
# Created by TechCentre with the help and assistance of the internet
3-
(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 }} | Format-Table -AutoSize
1+
<#
2+
.NOTES
3+
v1.1 8/23/2024 silversword411 complete refactor to add Connection mode column
4+
#>
5+
6+
# Get the list of saved SSIDs
7+
$wifiProfiles = (netsh wlan show profiles) | Select-String "\:(.+)$" | % { $_.Matches.Groups[1].Value.Trim() }
8+
9+
$results = @()
10+
11+
foreach ($name in $wifiProfiles) {
12+
$profileDetails = netsh wlan show profile name="$name" key=clear
13+
14+
# Look for the "Connection mode" setting
15+
$connectionModeMatch = $profileDetails | Select-String "Connection mode\W+\:(.+)$"
16+
$connectionMode = if ($connectionModeMatch) { $connectionModeMatch.Matches.Groups[1].Value.Trim() } else { "Not found" }
17+
18+
# Look for the password
19+
$passwordMatch = $profileDetails | Select-String "Key Content\W+\:(.+)$"
20+
$password = if ($passwordMatch) { $passwordMatch.Matches.Groups[1].Value.Trim() } else { "No password" }
21+
22+
$results += [PSCustomObject]@{
23+
SSID = $name
24+
PASSWORD = $password
25+
CONNECTION_MODE = $connectionMode
26+
}
27+
}
28+
29+
# Output the results in a table
30+
$results | Format-Table -AutoSize

scripts_wip/DUPE_Win_Network_Wifi_SSID_and_Password_Retrieval.ps1

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)