Public/Convert/Convert-HexToARGB.ps1

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
47
48
49
50
51
function Convert-HexToARGB {

    [cmdletbinding()]
    Param(
        [parameter(Mandatory=$True)]
        [string]$Hex_Val
    )

    Begin{}

    Process {
        #-Convert values
        $A = [Convert]::ToInt32($Hex_Val.substring(1, 2), 16)
        $R = [Convert]::ToInt32($Hex_Val.substring(3, 2), 16)
        $G = [Convert]::ToInt32($Hex_Val.substring(5, 2), 16)
        $B = [Convert]::ToInt32($Hex_Val.substring(7, 2), 16)
        
        #-Output value object
        $Obj = New-Object -Type PSObject
        $Obj | Add-Member -MemberType NoteProperty -Name A –Value $A
        $Obj | Add-Member -MemberType NoteProperty -Name R –Value $R
        $Obj | Add-Member -MemberType NoteProperty -Name G –Value $G
        $Obj | Add-Member -MemberType NoteProperty -Name B –Value $B
        $Obj       
    }

    End{}
    <#
  .SYNOPSIS
   Converts Hex to ARGB values
 
  .DESCRIPTION
   Converts Hex to ARGB values. Hex values are needed to apply ISE colors in script
 
  .PARAMETER Hex_Val
   An 8 character Hex value
 
        .EXAMPLE
   PS C:\> $ARGB = Convert-HexToARGB $HexValue
 
            Assigns converted hex value to ARGB variable
 
  .NOTES
            Part of the ISEColorThemeCmdlets.ps1 Script by Jeff Pollock
            http://Lifeinpowerhsell.blogspot.com
            http://gallery.technet.microsoft.com/ISE-Color-Theme-Cmdlets-24905f9e
 #>


}