Skip to content

Instantly share code, notes, and snippets.

@Noxsios
Last active September 25, 2023 22:40
Show Gist options
  • Save Noxsios/7b98e302dc33e444d44620798ad5f7f4 to your computer and use it in GitHub Desktop.
Save Noxsios/7b98e302dc33e444d44620798ad5f7f4 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