Controlling Wireless Connections from CLI

Today I had the need, to be able to turn the wireless adapter in a tablet on and off, and be able to connect to a known wireless network, from a script. I wasn't fussy, either a batch file or powershell script would work.

The rather simple solution, was found over at http://www.hanselman.com/ in his blog post How to connect to a Wireless WIFI Network from the Command line in Windows 7

Credit to Scott Hanselman

The NetSh commands work well in this instance.

Disconnect the wireless adapter from the wireless network:

netsh wlan disconnect

Connect to a known wireless network

netsh wlan connect name=<WIFI NAME>

Show all wireless networks

netsh wlan show profile

For Powershell versions of the command, check out Scripting Guys Posts; Hey Scripting Guy