Skip to content

Instantly share code, notes, and snippets.

@quietjoy
Last active February 11, 2023 15:20
Show Gist options
  • Save quietjoy/33284795f8fa41aaa74ae96d80d2b29d to your computer and use it in GitHub Desktop.
Save quietjoy/33284795f8fa41aaa74ae96d80d2b29d to your computer and use it in GitHub Desktop.
Get wifi networks and passwords
# 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