Skip to content

Instantly share code, notes, and snippets.

@cmwylie19
Forked from Noxsios/Get-WiFiProfiles.ps1
Created September 25, 2023 22:40
Show Gist options
  • Save cmwylie19/a4c7ffd9c1c7c7741fe10fde07706ce6 to your computer and use it in GitHub Desktop.
Save cmwylie19/a4c7ffd9c1c7c7741fe10fde07706ce6 to your computer and use it in GitHub Desktop.
Get-WiFi-Profiles using netsh and store in a TOML file for easy reading.
if (!(Test-Path "./profiles.toml")) {
New-Item -ItemType File "./profiles.toml" | Out-Null
}
"#####`n[profiles]" | Out-File -Append -Encoding utf8 "./profiles.toml"
(netsh wlan show profiles) |
Select-String "\:(.+)$" |
ForEach-Object {
$name = $PSItem.Matches.Groups[1].Value.Trim()
$PSItem
} |
ForEach-Object {
(netsh wlan show profile name="$name" key=clear)
} |
Select-String "Key Content\W+\:(.+)$" |
ForEach-Object {
$secret = $PSItem.Matches.Groups[1].Value.Trim()
$PSItem
} |
ForEach-Object {
"$name = $secret" | Out-File -Append -Encoding utf8 "./profiles.toml"
}
$ts = Get-Date -UFormat "%m-%d-%y %R"
"`n[timestamp]`nts = $ts" | Out-File -Append -Encoding utf8 "./profiles.toml"
((Get-Content .\profiles.toml) -join "`n" -split "#####")[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment