We will assume that the input is going to be with or without the # (as in, 55bc9a or #55bc9a).
- Open a new PowerShell file and type the following:
$Rgb = Read-Host "Enter the hexadecimal RGB value" $TrimmedRgb = $Rgb.Substring($Rgb.Length - 6) $R = $TrimmedRgb.Substring(0, 2) $G = $TrimmedRgb.Substring(2, 2) $B = $TrimmedRgb.Substring(4, 2) "Here are the R, G and B levels for the supplied hex value:" $R, $G, $B | ForEach-Object { [int]("0x" + $PSItem) }
- Run the script.
- Enter any valid hexadecimal RGB value, with or without the preceding #. Press Enter.
Here is an example.