In the previous tip we introduced the free PowerShell module Get-WLANs which can access the Windows Wi-Fi framework and return information such as signal strengths. Here is the command to download and install it:
Install-Module -Name Get-WLANs -Scope CurrentUser -Force
While you can simply use its new command Get-WLANs (as described in the previous tip), the module also adds a new .NET type that you can use once you ran the command. Run this first to initialize the new .NET type:
# "initialize" the new type $null = Get-WLANs
Next, get yourself a raw “WlanClient” object:
$wc = [NativeWifi.WlanClient]::New()
Now you can dump all the technical details about all available Wi-Fi adapters in your system:
PS> $wc.Interfaces Autoconf : True BssType : Any InterfaceState : Connected Channel : 36 RSSI : 29 RadioState : NativeWifi.Wlan+WlanRadioState CurrentOperationMode : ExtensibleStation CurrentConnection : NativeWifi.Wlan+WlanConnectionAttributes NetworkInterface : System.Net.NetworkInformation.SystemNetworkInterface InterfaceGuid : 7d6c33b7-0354-4ad7-a72f-5a1a5cbb1a9b InterfaceDescription : Killer(R) Wi-Fi 6 AX1650s 160MHz Wireless Network Adapter (201D2W) InterfaceName : WLAN
The “Interfaces” property returns an array, so your first Wi-Fi adapter is represented by:
$wc.Interfaces[0]
It offers a bunch of methods, i.e. to retrieve the list of available Wi-Fi networks in reach. This scans for new networks:
$wc.Interfaces[0].Scan() Start-Sleep -Seconds 1
And this dumps the list of networks in reach (including signal strength, frequency and channel):
PS> $wc.Interfaces[0].GetAvailableNetworkList(3) Dot11PhyTypes : {8} profileName : internetcafe dot11Ssid : NativeWifi.Wlan+Dot11Ssid dot11BssType : Infrastructure numberOfBssids : 3 networkConnectable : True wlanNotConnectableReason : Success morePhyTypes : False wlanSignalQuality : 81 securityEnabled : True dot11DefaultAuthAlgorithm : RSNA_PSK dot11DefaultCipherAlgorithm : CCMP flags : Connected, HasProfile (...)
This object model now provides you with a rich set of methods and properties to control and manage your Wi-Fi network adapters. For example, this line dumps a list of available SSIDs and their signal strength:
$ssid = @{ N='SSID' E={ [System.Text.Encoding]::Ascii.GetString( $_.dot11ssid.SSID, 0, $_.dot11ssid.SSIDLength ) } } $wc.Interfaces[0].GetAvailableNetworkList(3) | Select-Object -Property $ssid, wlanSignalQuality, profileName | Where-Object SSID
The result looks like this:
SSID wlanSignalQuality profileName ---- ----------------- ----------- internetcafe 81 internetcafe internetcafe 87 internetcafe 2 internetcafe 87 DIRECT-fb-HP M477 LaserJet 31 Guest 67