如何使用PowerShell列出附近的蓝牙设备

7
如何列出所有已配对或当前在我附近的蓝牙设备,并特别是 MAC 地址?我想要相当于以下命令的等效命令:
netsh wlan show network mode=bssid

我可以使用以下命令列出所有蓝牙设备和特征,但无法列出MAC地址:

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

请注意,如果我需要手动缩小结果并且列表不是完美的布局,这并不是问题。
2个回答

4

PowerShell 命令:

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

将打印已配对的设备:

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

XX:XX:XX:XX:XX 的值是您的蓝牙 MAC 地址。


它需要管理员权限才能运行 :( - daniol

0

使用注册表子键 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"
    }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接