Skip to content

Instantly share code, notes, and snippets.

@milesgratz
Created June 15, 2017 13:52
Show Gist options
  • Save milesgratz/669fe01f1fa0b64f9507f038458ba0fe to your computer and use it in GitHub Desktop.
Save milesgratz/669fe01f1fa0b64f9507f038458ba0fe to your computer and use it in GitHub Desktop.
Parse PowerShell_ISE theme for RGB values
$File = 'C:\Users\miles.gratz\desktop\Dark Console Light Editor default.StorableColorTheme.ps1xml'
$Content = Get-Content $file
$Results = @()
$Index = 0
foreach ($line in $content)
{
if ($line -match "\<string\>")
{
$key = (($line -split "<string>")[1] -split "</string>")[0]
$object = New-Object PSCustomObject
$object | Add-Member -MemberType NoteProperty -Name "Key" -Value $key
$object | Add-Member -MemberType NoteProperty -Name "A" -Value $null
$object | Add-Member -MemberType NoteProperty -Name "R" -Value $null
$object | Add-Member -MemberType NoteProperty -Name "G" -Value $null
$object | Add-Member -MemberType NoteProperty -Name "B" -Value $null
$Results += $object
}
if ($line -match "\<A\>")
{
$value = (($line -split "<A>")[1] -split "</A>")[0]
$Results[$index].'A' = $value
}
if ($line -match "\<R\>")
{
$value = (($line -split "<R>")[1] -split "</R>")[0]
$Results[$index].'R' = $value
}
if ($line -match "\<G\>")
{
$value = (($line -split "<G>")[1] -split "</G>")[0]
$Results[$index].'G' = $value
}
if ($line -match "\<B\>")
{
$value = (($line -split "<B>")[1] -split "</B>")[0]
$Results[$index].'B' = $value
$index++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment