# Script to fetch list of previously connected Wi-Fi networks on Windows

Administrators might want to monitor the Wi-Fi networks that their corporate devices connect to. It helps them ensure that the devices only connect to safe Wi-Fi networks. Hexnode lets admins [deploy scripts](https://www.hexnode.com/mobile-device-management/help/executing-custom-scripts-for-windows/) to get a list of previously connected Wi-Fi networks.

 Note: 
**Supported Versions**:

The scripts given below will be supported on the following versions:

- Windows 10 v1607+ (Pro, Enterprise, Education)
- Windows 11 (Pro, Enterprise, Education)

[ ](https://developer.android.com/develop/connectivity/uwb#uwb-enabled_mobile_devices)

 

 Disclaimer:The Sample Scripts provided below are adapted from third-party Open-Source sites.

 

Fetch the list of previously connected Wi-Fi networks 
------------------------------------------------------

When the device is connected to a Wi-Fi network, it creates a WLAN profile that consists of details specific to the network.

Batch script
------------

The following Batch script retrieves a list of all Wi-Fi networks accessed from the device.

Sample .bat script to fetch the list of previously connected Wi-Fi networks

@echo off Echo | netsh wlan show profile 

   1

2

  @echo off 

Echo | netsh wlan show profile 

   

 

  

PowerShell Scropt
-----------------

The PowerShell script to obtain the previously accessed Wi-Fi networks from a Windows device takes the following form:

Sample .ps1 script to fetch the list of previously connected Wi-Fi networks

Netsh wlan show profiles |Write-Output 

   1

  Netsh wlan show profiles |Write-Output 

   

 

  

 Notes:- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.