ARGB stands for Alpha Red Green Blue and is something I use quite often when I work with a WPF and want to get a color for font or something else. Basically, if you want a color like Green, sometimes you have to use the ARGB type, which is #FF008000. Figuring out what this is can be annoying unless you have web access. Fortunately, I wrote a simple function that can do this for me with little effort. While not everyone will find this useful, I figured I would post the code here along with some examples.
Function Get-ARGBColor {
Param ([string[]]$Color)
Begin {
Add-Type –assemblyName PresentationFramework
}
Process {
If (-Not $PSBoundParameters['Color']) {
$Color = [windows.media.colors] | Get-Member -static -Type Property | Select -Expand Name
}
ForEach ($c in $color) {
Try {
$ARGB = [windows.media.color]$c
New-Object PSObject -Property @{
ARGB = "$([windows.media.colors]::$c)"
Color = $c
}
} Catch {
Write-Warning "$c is not a valid color"
}
}
}
}
Get-ARGBColor -Color Green
Get-ARGBColor -Color Red,Yellow,Blue
If you just want to list out all available pre-defined colors, just run the command without any parameters.
