Public/Tools/Get-ValueDisplayName.ps1

function Get-ValueDisplayName {
    <#
    .SYNOPSIS
        Gets the display name of the value of a property.
    .DESCRIPTION
        Some propertie values such as FPS or Resolution might have different property names by which those values
        are referenced depending on the camera driver. For example, some cameras use the propery name 'Resolution'
        to refer to camera resolution, and others might use 'StreamProperty'. And the value for resolution might be
        '6' internally, while the display name for that value might be 1920x1080 for example.
 
        This function simplifies the process of finding out the best display name to use for the value of a property.
    .EXAMPLE
        PS C:\> Get-ValueDisplayName -PropertyList (Select-Camera | Get-StreamProperties -StreamNumber 0) -PropertyName 'Resolution', 'StreamProperty'
        Presents a camera selection dialog and then returns the display name for the configured resolution for the camera from the first video stream's settings.
    #>

    [CmdletBinding()]
    [OutputType([string])]
    param (
        [Parameter(Mandatory)]
        [VideoOS.ConfigurationApi.ClientService.Property[]]
        $PropertyList,

        [Parameter(Mandatory)]
        [string[]]
        $PropertyName,

        [Parameter()]
        [string]
        $DefaultValue = 'NotAvailable'
    )

    process {
        $value = $DefaultValue
        if ($null -eq $PropertyList -or $PropertyList.Count -eq 0) {
            return $value
        }

        $selectedProperty = $null
        foreach ($property in $PropertyList) {
            foreach ($name in $PropertyName) {
                if ($property.Key -like "*/$name/*") {
                    $selectedProperty = $property
                    break
                }
            }
            if ($null -ne $selectedProperty) { break }
        }
        if ($null -ne $selectedProperty) {
            $value = $selectedProperty.Value
            if ($selectedProperty.ValueType -eq 'Enum') {
                $displayName = ($selectedProperty.ValueTypeInfos | Where-Object Value -eq $selectedProperty.Value).Name
                if (![string]::IsNullOrWhiteSpace($displayName)) {
                    $value = $displayName
                }
            }
        }
        Write-Output $value
    }
}