-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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