Public/Hardware/Get-BluetoothVersion.ps1

<#
Copyright © 2024 Integris. For internal company use only. All rights reserved.
#>


FUNCTION Get-BluetoothVersion {
    <#
    .SYNOPSIS
    Retrieves the Bluetooth version of connected devices.
 
    .DESCRIPTION
    This function identifies and returns the Bluetooth version for each connected Bluetooth device by querying device properties.
 
    .PARAMETER None
 
    .EXAMPLE
    Get-BluetoothVersion
 
    .NOTES
    The function uses the Get-PnpDevice and Get-PnpDeviceProperty cmdlets to gather information about Bluetooth devices and their versions.
    #>


    [CmdletBinding()]
    PARAM ( )

    RETURN (Get-PnpDevice -Class 'Bluetooth' |
    Select-Object FriendlyName, InstanceID -PipelineVariable BTDevice |
    Foreach-Object InstanceId |
    Foreach-Object {Get-PnpDeviceProperty -InstanceId $_ }|
    Where-Object { $_.KeyName -eq '{A92F26CA-EDA7-4B1D-9DB2-27B68AA5A2EB}4' -Or $_.KeyName -eq 'DEVPKEY_Bluetooth_RadioLmpVersion' }|
    Select-Object @{l='Description'; e={ $BTDevice.FriendlyName }},
        @{l='InstanceId'; e={ $BTDevice.InstanceId }},
        @{ l='Version'; e={ switch ($_.Data) { 0 {'1.0b'} 1 {'1.1'} 2 {'1.2'} 3 {'2.0 + EDR'} 4 {'2.1 + EDR'} 5 {'3.0 + HS'} 6 {'4.0'} 7 {'4.1'} 8 {'4.2'} 9 {'5.0'} 10 {'5.1'} 11 {'5.2'} 12 {'5.3'} 13 {'5.4'} 14 {'6.0'}  } } }).Version 
}