PoshCode Archive  Artifact [e998d424d6]

Artifact e998d424d629e7feee8d550335fefc70b07e70ca404a42fe52eb301927cf2369:

  • File Wireless-Signal-Strength.ps1 — part of check-in [4138e035f3] at 2018-06-10 13:15:20 on branch trunk — There are a couple scripts that parse netsh commands. I didn’t see this one already done, so I couldn’t steal it. I suppose I could use some regex or something simple to cut the whitespace, so feel free to “fix her up”, but this got the job done (of putting the netsh output into an object). This is a snip from a larger script I wrote as a looping, recording monitor. I used this guy’s script for inspiration: http://poshcode.org/1731 (user: Josh Popp size: 2216)

# encoding: ascii
# api: powershell
# title: Wireless Signal Strength
# description: There are a couple scripts that parse netsh commands.  I didn’t see this one already done, so I couldn’t steal it.  I suppose I could use some regex or something simple to cut the whitespace, so feel free to “fix her up”, but this got the job done (of putting the netsh output into an object).  This is a snip from a larger script I wrote as a looping, recording monitor.  I used this guy’s script for inspiration: http://poshcode.org/1731
# version: 0.1
# author: Josh Popp
# license: CC0
# x-poshcode-id: 2757
# x-archived: 2016-05-29T07:40:00
# x-published: 2012-06-29T15:14:00
#
#
# Wireless Statistics into object
# Author: Josh Popp
# Put Wireless Stats, like Signal Strengh, BSSID, and Channel into an object

# First just dump the netsh output into $wlanraw 
    $wlanraw = netsh wlan show interface

# Create the object as "empty"
    $objWLAN = "" | Select-Object Name,SSID,BSSID,Channel,ReceiveRate,TransmitRate,Signal

# Populate the object from the output, processing 1 line at a time
    ForEach ($Line in $wlanraw) {
        
    	if ([regex]::IsMatch($Line,"    Name")) {
    		$objWLAN.Name = $Line -Replace "    Name                   : ",""
    		}
               
	if ([regex]::IsMatch($Line,"    SSID")) {
		$objWLAN.SSID = $Line -Replace"    SSID                   : ",""
    	       	}
               
         if ([regex]::IsMatch($Line,"    BSSID")) {
    	 	$objWLAN.BSSID = $Line -Replace"    BSSID                  : ",""
		}
               
	if ([regex]::IsMatch($Line,"    Channel")) {
    	   	$objWLAN.Channel = $Line -replace "    Channel                : ",""
		}
               
	if ([regex]::IsMatch($Line,"    Receive rate")) {
    	   	$objWLAN.ReceiveRate = $Line -replace "    Receive rate \(Mbps\)    : ",""
		}   
               
	if ([regex]::IsMatch($Line,"    Transmit rate")) {
    	   	$objWLAN.TransmitRate = $Line -replace "    Transmit rate \(Mbps\)   : ",""
		}  
               
	if ([regex]::IsMatch($Line,"    Signal")) {
    	   	$objWLAN.Signal = $Line -replace "    Signal                 : ",""
		}
        	}