Skip to content

*.dannyg

an extension of dannyg

Menu
  • Home
  • art
  • inspiration
  • music
  • poetry
  • Recipes
  • writings
Menu

Powershell Script: Convert RGB to HEX

Posted on March 1, 2011

Sometimes when I’m doing web programming (namely CSS), I need to quickly convert RGB to HEX.  So, I have written a neat little Powershell script.  Keep in mind that you might have to enable the ability to run Powershell scripts on your system (if you haven’t already, there are plenty of sites out there that show how to do this).  You should save this script as RGB2HEX.ps1

 

foreach ($arg in $args)
{
    $hexval = $hexval + [Convert]::ToString($arg, 16).ToUpper() 
}
 
Write-Host "Hex value :: $hexval"

To run this on the Powershell Console, do the following (in this case I’m testing converting 255 255 255 to hex)

.RGB2HEX.ps1 255 255 255

image

Leave a Reply

You must be logged in to post a comment.

Recent Posts

  • Reading Room
  • Inspirational Movies / TV shows
  • Remove passphrase from PEM file
  • Parallels Multihoming a CentOS Server
  • Forced Failures

Archives

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2026 *.dannyg | Design: Newspaperly WordPress Theme