Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Translating colors to hex and back

Reply
 
Old 03-09-2007   #11 (permalink)
Thomas Lee


 
 

Re: Translating colors to hex and back

In message <F6562493-22E2-48D9-9893-057C85AB0F72@microsoft.com>,
"/\\/\\o\\/\\/ [MVP]" <mow001@hotmail.NoSpam> writes
>Ok, but ( curiosity killed the cat ) what is white ?
>
>PoSH> [enum]::GetNames([System.ConsoleColor]) |% {$_;"{0:x}" -f
>([drawing.Color]$_).ToArgb()}


Cool!

So why does this fail:

PSH [D:\foo]: $e="[enum]::GetNames([system.consolecolor])"
PSH [D:\foo]: $e
[enum]::GetNames([system.consolecolor])
PSH [D:\foo]: & $e
The term '[enum]::GetNames([system.consolecolor])' is not recognized as
a cmdlet, function, operable program, or script file. Ver
ify the term and try again.
At line:1 char:2
+ & <<<< $e

Whereas this works fine when typed from the commend line

PSH [D:\foo]: [enum]::GetNames([system.consolecolor])
Black
DarkBlue
DarkGreen
DarkCyan
DarkRed
DarkMagenta
DarkYellow
Gray
DarkGray
Blue
Green
Cyan
Red
Magenta
Yellow
White
PSH [D:\foo]:
--
Thomas Lee
doctordns@gmail.com
MVP - Admin Frameworks and Security

My System SpecsSystem Spec
Old 03-09-2007   #12 (permalink)
Keith Hill


 
 

Re: Translating colors to hex and back

"Thomas Lee" <tfl@psp.co.uk> wrote in message
news:gnAUx3jgZY8FFAY$@mail.psp.co.uk...
> In message <F6562493-22E2-48D9-9893-057C85AB0F72@microsoft.com>,
> "/\\/\\o\\/\\/ [MVP]" <mow001@hotmail.NoSpam> writes
> So why does this fail:
>
> PSH [D:\foo]: $e="[enum]::GetNames([system.consolecolor])"
> PSH [D:\foo]: $e
> [enum]::GetNames([system.consolecolor])
> PSH [D:\foo]: & $e
> The term '[enum]::GetNames([system.consolecolor])' is not recognized as a
> cmdlet, function, operable program, or script file. Ver
> ify the term and try again.
> At line:1 char:2
> + & <<<< $e


With a string, you want to use Invoke-Expression e.g.:

2> $e="[enum]::GetNames([system.consolecolor])"
3> Invoke-Expression $e
Black
DarkBlue
DarkGreen
DarkCyan
DarkRed
DarkMagenta
DarkYellow
Gray
DarkGray
Blue
Green
Cyan
Red
Magenta
Yellow
White

If you want to call the code later then put it in a scriptblock.

4> $e={[enum]::GetNames([system.consolecolor])}
5> &$e
Black
DarkBlue
DarkGreen
DarkCyan
DarkRed
DarkMagenta
DarkYellow
Gray
DarkGray
Blue
Green
Cyan
Red
Magenta
Yellow
White

--
Keith

My System SpecsSystem Spec
Old 03-11-2007   #13 (permalink)
Thomas Lee


 
 

Re: Translating colors to hex and back

In message <9B2E0097-8A08-41C1-84C5-B1E305DCA059@microsoft.com>, Keith
Hill <r_keith_hill@mailhot.nospamIdotcom> writes
>If you want to call the code later then put it in a scriptblock.
>
>4> $e={[enum]::GetNames([system.consolecolor])}
>5> &$e


I knew that... :-)

Thanks.

Thomas
--
Thomas Lee
doctordns@gmail.com
MVP - Admin Frameworks and Security
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Translating English to Polish .NET General
Translating Japanese to English In a browser Browsers & Mail
help translating winrm authendication to powershell PowerShell
VISTA feels like going back to the Stone Age (in nice colors) [Edited] Vista General
Windows Mail Stationery Stopped Working, Also Font colors and background colors... Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46