Setting Powershell colors with hexadecimal values โ€‹โ€‹in profile script

I know that I can change the colors of the PowerShell console by setting something like:

$Host.UI.RawUI.BackgroundColor = "White" Clear-Host 

However, in the Powershell console, you can go to the Color tab in Properties and manually change the RGB values โ€‹โ€‹of the 16 ANSI standard colors. Is it possible to set either hexadecimal or RGB values โ€‹โ€‹of standard colors from a script profile? For example, the setup I would like to have:

 $Host.UI.RawUI.BackgroundColor = "#242424" # Gray Clear-Host 
+9
colors powershell
source share
4 answers

You can, but not through the $Host object. The color table is stored in the registry.

You would use the same names, but the colors would be different. Therefore, the PowerShell console defaults to blue / gray.

+5
source share

The correct way to do this is with the registry

 cd hkcu:/console $0 = '%systemroot%_system32_windowspowershell_v1.0_powershell.exe' ni $0 -f sp $0 ColorTable00 0x00562401 sp $0 ColorTable07 0x00f0edee 

With color

 0x00BBGGRR 
+4
source share

I doubt it is possible. $ Host.UI.RawUI.BackgroundColour is the System.ConsoleColor enumerator, so you can only select the final set of colors. http://msdn.microsoft.com/en-GB/library/system.consolecolor.aspx

+3
source share

As far as I know, you cannot. The console API does not support custom color. If you do this:

 $x = (Get-Host).UI.RawUI $x | gm 

you will see that BackgroundColor is of type System.ConsoleColor .

+1
source share

All Articles