Created
July 2, 2013 16:29
-
-
Save AzureKitsune/5910834 to your computer and use it in GitHub Desktop.
Wraps 'netsh wlan show networks' to print out the available wifi networks.
This file contains hidden or 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
$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