Skip to content

Instantly share code, notes, and snippets.

@AzureKitsune
Created July 2, 2013 16:29
Show Gist options
  • Save AzureKitsune/5910834 to your computer and use it in GitHub Desktop.
Save AzureKitsune/5910834 to your computer and use it in GitHub Desktop.
Wraps 'netsh wlan show networks' to print out the available wifi networks.
$procInfo = New-Object -TypeName "System.Diagnostics.ProcessStartInfo"
$procInfo.UseShellExecute = 0
$procInfo.Filename = "netsh"
$procInfo.Arguments = "wlan show networks mode=bssid"
$procInfo.CreateNoWIndow = 1
$procInfo.RedirectStandardOutput = 1
$proc = [System.Diagnostics.Process]::Start($procInfo)
#$proc.WaitForExit()
$stdout = $proc.StandardOutput
$output = ""
while($stdout.EndOfStream -eq 0)
{
$output += $stdout.ReadLine()
}
$networks = $output | Select-String -AllMatches -Pattern "SSID \d : (?<ssid>.+?\W).+?Authentication.+?: (?<auth>(Open|WPA2-Personal|)).+?Signal.+?: (?<signal>.+?%)"
foreach($match in $networks.Matches)
{
$network = $match.Groups["ssid"].Value
$auth = $match.Groups["auth"].Value
$signal = $match.Groups["signal"].Value
write-output $network
write-output $auth
write-output $signal
write-output "-----"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment