Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Parse netsh output like this into a hashtable so can easily use in scripts, etc
- # Transmit rate (Mbps) : 57.8
- [hashtable]$wlan = @{};netsh.exe wlan show interfaces | ForEach-Object{ if( $_ -match '(\w[^:]+):\s+?(\w.*)$' -and ! [string]::IsNullOrEmpty( $matches[2] ) ) { $wlan.Add( $matches[1].Trim() , $matches[2] )}}
- # Using the above to implement a signal strength monitor that updates every 5 seconds
- While($true){ [hashtable]$wlan = @{};netsh.exe wlan show interfaces | ForEach-Object{ if( $_ -match '(\w[^:]+):\s+?(\w.*)$' -and ! [string]::IsNullOrEmpty( $matches[2] ) ) { $wlan.Add( $matches[1].Trim() , $matches[2] )}} ; "{0} {1} {2:4} {3}" -f (Get-Date -Format G) , $wlan.SSID , $wlan.Signal , ( "$([char]4)" * [int]($wlan.Signal -replace '%') ) ; start-sleep 5 }
Add Comment
Please, Sign In to add comment