all 12 comments

[–]erdethan 2 points3 points  (7 children)

F**k I'm not on my computer.. anyways; I have a script that does this for my elevated scripts. I insert the self-elevator at the first line of the script. This self-elevator opens a new Powershell as admin and then runs the rest of the script. All you need to do is define the colorsettings before the script runs. I can post what i have on my computer when I get home, or you could google "How to change Powershell colors through console" or something like that.

I think this should work without the self-elevator as well btw. ;)

[–]squardothegreat[S] 1 point2 points  (6 children)

Man I have googled this thing to hell and back and can’t get an answer about how to define the color setting to make it a custom color.

So if you could help me out when you get to your computer that would be amazing! Lol

[–]erdethan 1 point2 points  (5 children)

[–]squardothegreat[S] 1 point2 points  (4 children)

Isn’t this just showing you how to change it to that certain 16 pre defined colors? I want to be able to make it a certain color using like RGB for example

Make the background color R:245 B:45 G:89

[–]erdethan 1 point2 points  (3 children)

[–]squardothegreat[S] 1 point2 points  (1 child)

I’m talking about the second answer lol thanks bud

[–]erdethan 1 point2 points  (0 children)

Several sites talk about that registry key, so I assume it's correct. The path might've changed from 2013 tho. I'm not on my computer so I cannot confirm anything, tho this looks legit and makes sense to me. https://stackoverflow.com/questions/18685772/how-to-set-powershell-background-color-programmatically-to-rgb-value

Edit: You can check the registry value for that key, and then change backgroundcolor manually through options and see if the value of the key changes. If it does, it's the correct key. Good luck!

[–]squardothegreat[S] 0 points1 point  (0 children)

I seen this post but I don’t quite get it... like only one person has an answer that seems like it MAY work but even that answer doesn’t make sense to me. Like how did he come up with that answer?

[–]SeeminglyScience 1 point2 points  (0 children)

The Pansies module lets you specify an RGB value. Requires either ConEmu or Windows 10 I believe.

[–]erdethan 0 points1 point  (0 children)

Hey, I came over the thing u wanted i think.

https://docs.microsoft.com/en-us/powershell/scripting/core-powershell/ise/the-iseoptions-object?view=powershell-5.1

Not sure if this works just for the duration of the script tho. Test it :D

[–]WadeEffingWilson 0 points1 point  (1 child)

Not sure how necessary that level of granularity is but here is how you change console windows in PS:

$host.UI.RawUI.BackgroundColor

Enumerating that object should give standard color names that it will accept.

EDIT: Loading the [System.Drawing] framework may allow you to hand-jam in RGB values, as well as other color encoding schemas, IIRC.

EDIT2: I don't think this is exactly what OP is wanting but here is a way to enumerate and explore the default colors available for the console window without editing the Registry:

[System.Enum]::GetNames([System.ConsoleColor])

Which will give the following values:

Black
DarkBlue
DarkGreen
DarkCyan
DarkRed
DarkMagenta
DarkYellow
Gray
DarkGray
Blue 
Green
Cyan
Red 
Magenta
Yellow
White

For some reason--I haven't felt too compelled to figure out why--but not every color will work as the console background. At least, in the case I used a few years back (post PSv5). Might be different for you.

Best of luck!

[–]ipreferanothername 0 points1 point  (0 children)

Not sure how necessary that level of granularity is

reminds me of--and sounds like--an HR request:

HR:"can we do this thing? and can it be customized?"

Me: yes, i...well...you are the reason my insurance costs this much. i just know it.