How to list bluetooth devices near me using PowerShell
Asked Answered
A

2

7

How to list all Bluetooth devices paired or currently near me and particullary MAC adress ? I want the equivalent of the command :

netsh wlan show network mode=bssid

I am able to list all Bluetooth devices and characteristics but not MAC adress with the command :

Get-PnpDevice | Where-Object {$_.Class -eq "Bluetooth"}
foreach ($device in $devices) { echo $device.InstanceId }

Note it is not a problem if I need to manually shrink results and if the list is not in a perfect layout.

Aiden answered 18/11, 2020 at 7:46 Comment(0)
Q
4

The PowerShell command :

Get-ChildItem -Path HKLM:\SYSTEM\ControlSet001\Services\DeviceAssociationService\State\Store\ | Select-String -Pattern Bluetooth

will print devices already paired :

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\DeviceAssociationService\State\Store\Bluetooth#BluetoothXX:XX:XX:XX:XX:b2-YY:YY:YY:YY:YY:YY
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\DeviceAssociationService\State\Store\Bluetooth#BluetoothXX:XX:XX:XX:XX:b2-ZZ:ZZ:ZZ:ZZ:ZZ:ZZ
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\DeviceAssociationService\State\Store\BluetoothLE#BluetoothLEXX:XX:XX:XX:XX:b2-WW:WW:WW:WW:WW:WW

The XX:XX:XX:XX:XX values is your Bluetooth MAC adress.

Quattlebaum answered 18/11, 2020 at 19:52 Comment(1)
It needs administrative rights in order to work :(Leucocytosis
L
0

Use registry subkeys from Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\BTHPORT\Parameters\Devices:

$devices = Get-ChildItem -Path HKLM:\SYSTEM\ControlSet001\Services\BTHPORT\Parameters\Devices
foreach($device in $devices) {
    $address=$device.pschildname.ToUpper()
    $name=$device.GetValue("Name")
    if($name -ne $null) {
        $printableName = ($name -notmatch 0 | ForEach{[char]$_}) -join ""
        echo "Address: $address, Name: $printableName"
    }
}
Leucocytosis answered 7/3, 2023 at 7:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.