Public/Convert/Convert-ARGBToHex.ps1
function Convert-ARGBToHex { [cmdletbinding()] Param( [parameter(Mandatory=$True)] [string]$RGB_Val ) Begin{} Process { #-separate the ARGB values $var_RGB = $RGB_Val.split(',') #-Convert values to Hex $var_A = [Convert]::ToString($var_RGB[0], 16).ToUpper() $var_R = [Convert]::ToString($var_RGB[1], 16).ToUpper() $var_G = [Convert]::ToString($var_RGB[2], 16).ToUpper() $var_B = [Convert]::ToString($var_RGB[3], 16).ToUpper() #-pad single digit values to ensure 8 character Hex is returned If ($var_A.Length -eq 1) {$var_A = "0$var_A"} If ($var_R.Length -eq 1) {$var_R = "0$var_R"} If ($var_G.Length -eq 1) {$var_G = "0$var_G"} If ($var_B.Length -eq 1) {$var_B = "0$var_B"} #-Output concatenated hex value Write-Output "#$var_A$var_R$var_G$var_B" } End{} <# .SYNOPSIS Converts ARGB to Hex values .DESCRIPTION Converts ARGB to Hex values. ARGB values are needed to save console colors to xml format .PARAMETER Hex_Val The ARGB value .EXAMPLE PS C:\> $Hex = Convert-ARGBToHex $ARGBValue Assigns converted ARGB value to Hex variable .NOTES Part of the ISEColorThemeCmdlets.ps1 Script by Jeff Pollock http://Lifeinpowerhsell.blogspot.com http://gallery.technet.microsoft.com/ISE-Color-Theme-Cmdlets-24905f9e #> } |