How to show all known Wi-Fi network SSIDs and Passphrases with Powershell

I think is very important to remember how much information is stored on our laptops over the years, this is the case also for all wireless networks with (SSID and Passphrase) that our OS stores and use to connect automatically.

Retrieving this information can be performed either via the GUI or CLI, but I was never happy with the way the information was presented.

I simply needed the list of all the known wi-fi networks presented in a key-value pair format, so I’ve written this script a few months ago and I’ve now taken the opportunity to write an article about it.

It all started with Netsh

This script is quite simple thanks to the network shell (netsh), an ‘ancient‘ command-line utility written 20 years ago and sometimes still relevant today on windows servers or windows workstations.

My script is practically speaking a pure wrapper of a netsh script.

How to retrieve wi-fi network details via netsh

To retrieve all know networks with  netsh you can simply run on your terminal:

If you’re after one specific credential for your wi-fi network with SSID called “Guest-5G” you can simply run:

Let’s analyse the PowerShell script

The first assumption is that on your workstation there is a wireless profile, if there isn’t the message “There is no wireless interface on the system.” will be presented.

The Write-Warning line is a re-cap starting with the date and time when the script is executed with the total number of wifi networks stored.

The foreach loop enumerates all elements of the list of network retrieved by netsh and using a regex gets only the passphrase presenting the for each network SSID: PASSPHRASE as key-value pairs.

I hope you’ll find this script useful, as usual, you can find it in my Github repository.

One Reply to “How to show all known Wi-Fi network SSIDs and Passphrases with Powershell”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.