private/Convert/Convert-HexToARGB.ps1

function Convert-HexToARGB {
    <#
    .SYNOPSIS
        Converts a hexadecimal ARGB color string to its individual component values.
 
    .DESCRIPTION
        The Convert-HexToARGB function parses a hex color string in the format "#AARRGGBB" and returns
        a PSCustomObject with separate A, R, G, and B properties as integers. This is useful for decoding
        ISE theme values stored in registry or XML files into editable components.
 
    .PARAMETER Hex_Val
        A hex color string (e.g., "#FF0078FF") representing the alpha, red, green, and blue components.
 
    .EXAMPLE
        PS C:\> $ARGB = Convert-HexToARGB -Hex_Val "#FF0078FF"
        PS C:\> $ARGB.B
        255
 
        Returns a color object with discrete A, R, G, B values based on the input.
 
    .NOTES
        Author: Jeff Pollock
        GitHub: https://github.com/phriendx/ISEColorTheme.cmdlets
        Website: https://pxlabs.info
    #>


    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]$Hex_Val
    )

    process {
        if ($Hex_Val -notmatch '^#([A-Fa-f0-9]{8})$') {
            throw "Input must be a hex string in the format #AARRGGBB (e.g., '#FF0078FF')."
        }

        try {
            $A = [Convert]::ToInt32($Hex_Val.Substring(1, 2), 16)
            $R = [Convert]::ToInt32($Hex_Val.Substring(3, 2), 16)
            $G = [Convert]::ToInt32($Hex_Val.Substring(5, 2), 16)
            $B = [Convert]::ToInt32($Hex_Val.Substring(7, 2), 16)

            [pscustomobject]@{
                A = $A
                R = $R
                G = $G
                B = $B
            }
        }
        catch {
            throw "Conversion failed: $_"
        }
    }
}