Last active
February 11, 2023 15:20
-
-
Save quietjoy/33284795f8fa41aaa74ae96d80d2b29d to your computer and use it in GitHub Desktop.
Get wifi networks and passwords
This file contains 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
# The following is a powershell script to get all previously joined wifi networks and passwords for windows systems | |
# The number of lines skipped in the following command may need to be altered if "Group policy profiles" are available | |
$profiles = $(netsh wlan show profiles) -split "\n" | Select-Object -Skip 9 | Select -SkipLast 1 | |
foreach($profile in $profiles) | |
{ | |
$network = $profile.Split(":")[1].Replace(" ", "") | |
$info = $(netsh wlan show profile $network key=clear) | |
$key = $info | Select-String -Pattern "Key Content" | |
$cleanKey = If (!$key.Line) {"No Password Required"} Else {$key.Line.Split(":")[1].Replace(" ", "")} | |
Write-Output ("{0} - {1}" -f $network,$cleanKey) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment