Identifying Wi-Fi Signal Strength (Part 1)

by May 3, 2021

Provided you are connected to a wireless network, then the following one-liner gets you the current signal strength:

 
PS> @(netsh wlan show interfaces) -match '^\s+Signal' -replace '^\s+Signal\s+:\s+',''
80%   
 

The signal strength is taken from the text output provided by netsh.exe. Embracing it in @() makes sure it always returns an array. The -match operator then uses a regular expression to identify the line that contains the word “Signal” at a line beginning. A following -replace operator uses a regular expression to remove the text that prepends the signal strength.

If you hate regular expressions, you can achieve the same with other strategies, such as this:

 
PS> (@(netsh wlan show interfaces).Trim() -like 'Signal*').Split(':')[-1].Trim()
80%  
 

Here, each line returned by netsh.exe is first trimmed (removing white space from either end). Next, a classic -like operator selects the line that starts with “Signal”. This line then is splitted by “:”, and the last part (index -1) is used. The signal rating is trimmed again to remove whitespace around it.

Should both commands not return anything, then please check whether your machine is connected to a wireless network at all. You may also want to run the netsh.exe command just with its arguments and without any text operators to view the commands raw output.


Twitter This Tip! ReTweet this Tip!