суббота, 13 февраля 2016 г.

Get saved wi-fi passwords in Windows with PowerShell script

Powershell script which get a list of all saved wi-fi networks with passwords:

function Get-WifiNetworks {
  $networks = netsh wlan show profiles | where {$_ -match '^.*All User Profile.*$'}
  foreach ($network in $networks) {
    $SSID = $network.split(':')[1].Trim()
    $networkInfo = netsh wlan show profiles key=clear name="$SSID"
    $current = @{}
    $current['SSID']=$SSID
    foreach ($infoString in $networkInfo) {
        if ($infoString -match '^\s+(.*)\s+:\s+(.*)\s*$') {
            $current[$matches[1].trim()] = $matches[2].trim()           
        }
    }
    new-object psobject -property $current
  }
}
Get-WifiNetworks | select SSID, "Key Content", Authentication | Format-Table -Wrap -Autosize

Комментариев нет: