PowerShell/scripts/list-bluetooth-devices.ps1

26 lines
757 B
PowerShell
Raw Normal View History

2024-10-01 13:37:53 +02:00
<#
2021-12-03 12:49:05 +01:00
.SYNOPSIS
2022-10-24 15:51:54 +02:00
Lists Bluetooth devices
2021-12-03 12:49:05 +01:00
.DESCRIPTION
2024-05-30 14:08:00 +02:00
This PowerShell script lists all Bluetooth devices connected to the local computer.
2021-12-03 12:49:05 +01:00
.EXAMPLE
2023-08-06 21:35:36 +02:00
PS> ./list-bluetooth-devices.ps1
2024-05-30 14:08:00 +02:00
FriendlyName Status InstanceId
------------ ------ ----------
G3 Headset OK BTHENUM\DEV_FC58FA7A51C6\8&152049BE&0&BLUETOOTHDEVICE_FC58FA7A51C6
2023-08-06 21:35:36 +02:00
...
2021-12-03 12:49:05 +01:00
.LINK
https://github.com/fleschutz/PowerShell
2022-01-29 12:47:46 +01:00
.NOTES
2022-09-06 21:42:04 +02:00
Author: Markus Fleschutz | License: CC0
2021-12-03 12:49:05 +01:00
#>
try {
2024-05-31 11:41:29 +02:00
Get-PnpDevice | Where-Object {$_.Class -eq "Bluetooth"} | Sort-Object -property FriendlyName | Format-Table -property FriendlyName,Status,InstanceId
2021-12-03 12:49:05 +01:00
exit 0 # success
} catch {
2022-04-13 12:06:32 +02:00
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2021-12-03 12:49:05 +01:00
exit 1
}