public/Get/Get-ISETheme.ps1

function Get-ISETheme {
    <#
    .SYNOPSIS
        Retrieves a PowerShell ISE theme from a file or the registry.
 
    .DESCRIPTION
        The Get-ISETheme function reads a theme definition in .ps1xml format—either from a file or from the
        registry—and converts it into a structured set of color data. The result is an array of color elements
        representing token types, UI colors, and font metadata, each returned as a custom object.
 
    .PARAMETER File
        The full path to a .ps1xml theme file. This is used to load an ISE theme from disk.
 
    .PARAMETER ThemeName
        The name of a registered ISE theme to retrieve from the registry.
 
    .EXAMPLE
        Get-ISETheme -File 'C:\Themes\SolarizedDark.ps1xml'
 
        Loads and parses the SolarizedDark theme file into structured objects.
 
    .EXAMPLE
        Get-ISETheme -ThemeName 'CustomMonokai'
 
        Retrieves the 'CustomMonokai' theme from the registry.
 
    .NOTES
        Author: Jeff Pollock
        GitHub: https://github.com/phriendx/ISEColorTheme.cmdlets
        Website: https://pxlabs.info
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory, ParameterSetName='fromfile', ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
        [string]$File,

        [Parameter(Mandatory, ParameterSetName='fromreg', ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
        [string]$ThemeName
    )

    Begin {}

    Process {
        [xml]$xml = if ($File) {
            Get-Content -Path $File -Raw
        } else {
            $theme = Get-ItemProperty HKCU:\Software\Microsoft\PowerShell\3\Hosts\PowerShellISE\ColorThemes -Name $ThemeName
            $theme.$ThemeName
        }

        $xmlObjects = @()
        for ($i = 0; $i -lt $xml.StorableColorTheme.Keys.String.Count; $i++) {
            $key = $xml.StorableColorTheme.Keys.String[$i]
            $color = $xml.StorableColorTheme.Values.Color[$i]
            $hex = Convert-ARGBToHex "$($color.A),$($color.R),$($color.G),$($color.B)"

            $class, $attribute = if ($key -like "*\*") {
                $key -split '\\', 2
            } else {
                'Base', $key
            }

            $xmlObjects += [pscustomobject]@{
                Class     = $class
                Attribute = $attribute
                A         = $color.A
                R         = $color.R
                G         = $color.G
                B         = $color.B
                Hex       = $hex
            }
        }

        $xmlObjects += [pscustomobject]@{
            Class      = 'Other'
            Name       = $xml.StorableColorTheme.Name
            FontFamily = $xml.StorableColorTheme.FontFamily
            FontSize   = $xml.StorableColorTheme.FontSize
        }

        return $xmlObjects
    }

    End {}
}