windows


Why does PowerShell display “DarkYellow” text improperly?


I'm using the Write-Host cmdlet to change the color of my prompt and I noticed that the DarkYellow color was not displaying as any sort of yellow, but as a gray! Here's a test of all the colors
PS> 0..15 | %{ Write-Host "Hello, world!" -ForegroundColor $_ }
I got a list of all the enum values by using a bad value
PS> Write-Host "Hello, World!" -ForegroundColor foo
Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White
And I realized that this list of "console colors" somehow corresponds to the settings for this console window/shortcut, right? So, DarkYellow would be this 7th one in and it sure looks gray.
What's the connection between ForegroundColor, System.ConsoleColor, and these console shortcut settings? Why is dark yellow displaying as gray "out of the box"? Should I change it? Will this change every console on my system or just this shortcut?
Why are consoles so finnicky on Windows?!
I'm on Windows 7 Pro SP1 64-bit and I'm launching the "Windows PowerShell" shortcut from the Start Menu.
Lee Holmes' blog post, PowerShell's Noble Blue, talks about this a bit, but doesn't actually explain why DarkYellow was changed. Most likely the default DarkYellow was unreadable with the blue background.
As you've probably figured out - the System.ConsoleColor is slightly misnamed as it doesn't actually specify a color, it specifies an index into a color table which can be modified by shortcuts. This is unfortunately a limitation of the console subsystem.
If you change the shortcut PowerShell.lnk, you'll be changing the colors only for yourself and only when you start PowerShell from that link. If you use Start | Run, or say run cmd, then run PowerShell from cmd, you'll get different settings.
Lee's blog post should give you enough hints to get the behavior you prefer.
I don't have the exact answers, but I have something that kind of works! I did some research (thanks, Jason Shirk) and found that System.ConsoleColor is just an index into the color table, which must be represented by this
The documentation does mention that DarkYellow is supposed to be "ochre" (RGB: 204, 119, 34).
| DarkYellow | The color dark yellow (ochre). |
Choose "Defaults" from the application's top-left window menu and you'll see the generic "Console Windows Properties" (like above), which will modify any ConsoleWindowClass type window.
Pick the "Screen Text" option and you'll notice it's set to use the value in DarkYellow's spot. I don't know why they didn't use Gray or DarkGray right next to it! Click on the 7th box (the index for DarkYellow) and change it to ochre's RGB value. Then, set the "Screen Text" to the Gray or DarkGray (unless you really want ochre foreground text by default).
All of your Command Prompt, PowerShell, and Git Bash (mingw) consoles will be changed (mine were).
I did have a little trouble with the PowerShell prompt from the "run" dialog. It took the colors, but not some of my other settings (physical and buffer size, etc). I ended up using scoop to install concfg
PS> scoop install concfg
PS> scoop install sudo
and exported my good console settings
PS> concfg export > ~\.consolerc
and imported them into my misbehaving prompt with prejudice (you can use sudo, also from scoop, or just launch an admin prompt)
PS> sudo concfg import ~\.consolerc
And, actually, concfg seemed to export everything, the color table values and the selections! Here's a partial dump of my configuration (the color parts)
{
"popup_colors": "cyan,white",
"dark_gray": "#808080",
"screen_colors": "gray,dark_magenta",
"dark_green": "#008000",
"blue": "#0000ff",
"dark_yellow": "#cc7722",
"red": "#ff0000",
"magenta": "#ff00ff",
"dark_red": "#800000",
"yellow": "#ffff00",
"dark_magenta": "#012456",
"cyan": "#00ffff",
"green": "#00ff00",
"dark_blue": "#000080",
"gray": "#c0c0c0",
"white": "#ffffff",
"black": "#000000",
"dark_cyan": "#008080"
}

Related Links

Php Script to delete and create files and folder using .bat not working when run using Windows Scheduler
I am trying to make .jks file process automatic
Existing Directory Not Found by Batch Script
Express/connect 'connect.sid' session cookie not created windows 10
Batch file net user command
Escaping forward slashes : Windows CMD and Bash
Tab completion and arrow keys don't work in GHCI in Git Bash
.htaccess on filesystem not working
Windows 10 task scheduler errors “task not supported”
Windows Batch script - Get folder containing another folder, but not containing a certain parent folder
BAT/CMD file to remove drive letters using DISKPART
Powershell script on remote computer not running as a scheduled task
How to change specific registry setting for another user in powershell
Win 10 UAP ListView Conditional Separator
Using a Qt Help file in an installed app
PowerShell script to remove file from hidden folders

Categories

HOME
batch-file
xml
checkstyle
forms
jmeter
3d
hessian
javacc
limit
crystal-lang
trac
recordrtc
fosrestbundle
owin
gkturnbasedmatch
bitnami
atlassian-stash
aws-sdk
forgot-password
connector
delphi-xe5
sencha-touch
selinux
user-experience
inno-download-plugin
itunes
custom-post-type
android-sharedpreferences
has-and-belongs-to-many
ntp
constexpr
utorrent
weather
record
card.io
biztalk-rule-engine
xajax
engine.io
amazon-ses
sim-card
kill
plaintext
escpos
congestion-control
angular-http
x-ray
reindex
sundials
css-transforms
rackspace-cloud
cmp
objectscript
winusb
scaffolding
dimension
xdoclet
exim4
custom-errors
themoviedb-api
morton-number
slash
jdk1.7
sha512
branch-and-bound
mirror
snoop
mraid
zxspectrum
cakephp-2.7
theos
beatsmusic
post-commit-hook
psr-4
linkedin-jsapi
wcm
raygun
jqmodal
ray
ios8-extension
square-bracket
ecslidingviewcontroller
android-usb
hibernate-entitymanager
kendo-dataviz
route-provider
insert-id
android-sdk-2.3
onmousemove
ilasm
apache-commons-dbutils
luabind
ikimagebrowserview
landscape-portrait
cgbitmapcontextcreate
msr
twitterizer
collectionviewsource
luajava
office-2007
jqueryform
drupal-fivestar
web-application-project
lobo-cobra
fault-tolerance

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile