Private/ConvertFrom-RGBColor.ps1

function ConvertFrom-RGBColor {
    [OutputType([System.String])]
    [cmdletbinding()]
    param(
        [parameter(Mandatory, ValueFromPipeline)]
        [ValidateNotNullOrEmpty()]
        [string]$RGB
    )

    $RGB = $RGB.Replace('#', '')
    $r   = [convert]::ToInt32($RGB.SubString(0,2), 16)
    $g   = [convert]::ToInt32($RGB.SubString(2,2), 16)
    $b   = [convert]::ToInt32($RGB.SubString(4,2), 16)

    $escape = [char]27
    "${escape}[38;2;$r;$g;$b`m"
}