Showing posts with label netsh. Show all posts
Showing posts with label netsh. Show all posts

Wednesday, 21 September 2016

Getting Data Out of the Windows ‘netsh wlan show interfaces’ Command

I recently read a very nice article by Matt Frederick about using a Windows command prompt utility to gain information about what your Windows wireless adapter is up to while connected to a Wi-Fi network ( https://finesine.com/2016/09/17/using-netsh-wlan-show-interfaces-to-monitor-associationroaming/)


In  Matt’s article, he described how he wrapped the ‘netsh’ command into a nice little batch file to run the command regularly, allowing information to be presented in a more dynamic fashion.


I was so impressed with the information provided by the utility, that I decided I’d  try to get the information it provides into a more usable format. In short, I hacked together a Windows Powersell script that runs the ‘netsh’ CLI utility regularly and parses the output data into a CSV format.

By piping the output into a file, you can get a nice CSV file that can be opened in Excel to look at the raw data over a period of time. It’s great for looking at the adapter signal level and BSSID information - it’s easy to spot when your client roams and the approximate signal level at which this takes place.


Fig 1 - You can get output like this...unless you've got good eye-sight, it's better in a CSV :)


A few caveats:


  • I’m not  a coder - this is my first Powershell script
  • This isn’t a robust piece of supported code - it will break easily over time when the output of the ‘netsh’ command changes (refer to the previous bullet)
  • The ‘netsh’ utility natively provides RSSI data as  percentage figure. I’ve converted it to dBm in the script, but the highest dBm figure you’ll ever see is 50dBm ( which is 100% in the ‘netsh’ utility output)...don’t shoot the messenger on that one.
  • This was a bit of fun to do - have fun with it yourself, but don’t get too angry if it doesn't work for you :)
  • Open the script file with Notepad and read ALL of the notes at the top of the file that explain how to use the script.


There are a few challenges getting the script to run without lots of warnings in Powershell - open the script file and read the notes at the top of the file.


By default, the script runs every second, which is nice to roam around and capture regular data. Change the variable ‘$SleepInterval’ at the beginning of the code if you’d like to extend it to a more infrequent interval (2 = 2 secs, 3 = 3 secs etc…)

Again, have fun with it...oh yes, you can find the script here: https://github.com/wifinigel/win-wlan-data-script

References:


Saturday, 24 November 2012

Useful Win 7 Command for Wireless

This probably falls into that category: "stuff that everyone else already knows, but I don't", but I thought it was worth jotting down a few notes about.

I recently saw someone tweet about the command: "netsh show wlan <various options>", which I had never heard of before.

After having had a look through the command help screens, it seems an incredibly useful command if you want to quickly find out about the wireless networks and the wireless capabilities of a Windows 7 machine you're working on. Much of the information can be found by poking around in various GUI pages, but this command line utility is much quicker to use and gives a greater depth of information.

I'll just run through a few useful examples and then leave you to poke about in the help pages yourself if you want to know more.

A great way to get a summary of the wireless networks that a Win 7 client can hear is to open a command window (...or a DOS box as I like to call it) and enter the command: "netsh show wlan networks":


On the face of it, this maybe isn't massively impressive, but if you add the command switch "mode=BSSID", things get a little more interesting:


You now get to see some great information which includes authentication and encryption types, radio type (802.11g/n/a etc.) and channel. Very useful information.

 The final command variation I'll look at is: "netsh wlan show drivers". This command shows you extensive information about the radio types and authentication and encryption types supported by your wireless driver. I'm guessing that I need to caveat this by saying that there may be some hardware and even OS dependencies that need to be fulfilled for the client to actually support all of these:


Finally, there are plenty more options to play with, so have a poke about in the help screens and see if there are more useful nuggets you can find :) Here is the help screen output to whet your appetite:



(Update: I have been advised by a couple of very reliable people that this command also works on Windows 8)