Skip to content

Instantly share code, notes, and snippets.

@lewisgibson
Created September 14, 2023 10:42
Show Gist options
  • Save lewisgibson/a28ef9abaf8e125dd31e1227f477273e to your computer and use it in GitHub Desktop.
Save lewisgibson/a28ef9abaf8e125dd31e1227f477273e to your computer and use it in GitHub Desktop.

Revisions

  1. lewisgibson created this gist Sep 14, 2023.
    16 changes: 16 additions & 0 deletions wifi-passwords.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <#
    .SYNOPSIS
    This script retrieves Wi-Fi profiles and their associated passwords.
    .NOTES
    Author: Lewis Gibson
    #>

    $wifiProfiles = (netsh wlan show profiles) | Select-String "^\s+:\s(.+)$" | ForEach-Object {
    $name = $_.Matches.Groups[1].Value.Trim()
    $profileInfo = netsh wlan show profile name="$name" key=clear
    $pass = ($profileInfo | Select-String "Key Content\s+:\s(.+)$").Matches.Groups[1].Value.Trim()
    [PSCustomObject]@{ PROFILE_NAME = $name; PASSWORD = $pass }
    }

    $wifiProfiles | Format-Table -AutoSize