{"id":8877,"date":"2022-02-16T12:48:00","date_gmt":"2022-02-16T17:48:00","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=8877"},"modified":"2022-02-14T14:50:43","modified_gmt":"2022-02-14T19:50:43","slug":"even-more-colorful-fun-with-powershell-and-wpf","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/","title":{"rendered":"Even More Colorful Fun with PowerShell and WPF"},"content":{"rendered":"\n<p>Let's continue looking at how to use PowerShell and a Windows Presentation Foundation (WPF) form to display [System.Drawing.Color] values. This article builds on <a href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8871\/more-colorful-fun-with-powershell\/\" target=\"_blank\" rel=\"noreferrer noopener\">an earlier post <\/a>so if you missed it, take a few minutes to get caught up. As I did earlier, before running any WPF code in PowerShell, you should load the required type assemblies. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Add-Type -AssemblyName PresentationFramework<\/code><\/pre>\n\n\n\n<p>I should point out that this isn't an absolute requirement since some hosts like the PowerShell ISE will run WPF code without it. But you never know where your code is going to be executed, so it never hurts to run the Add-Type command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"multiple-color-display\">Multiple Color Display<\/h2>\n\n\n\n<p>I'm going to continue building on my earlier code. I like working incrementally. This allows me to identify potential obstacles and test techniques. My interim code should enable me to display multiple colors. Because this is a development function, I'll limit the number of colors to test to 10. I can use a ValidateCount() test for the parameter value.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Param(\n    [Parameter(\n        Position = 0,\n        Mandatory,\n        HelpMessage = \"Enter between 1 and 10 System.Drawing.Color names\"\n    )]\n    [ValidateCount(1, 10)]\n    [ValidatePattern(\"^\\w+$\")]\n    [string[]]$Color\n)<\/code><\/pre>\n\n\n\n<p>I am also adding a regex pattern test to ensure the color value is a simple string with no spaces. Yes, I realize I could improve this pattern, but it will suffice for my proof-of-concept needs.<\/p>\n\n\n\n<p>Nothing changes with the code to build the WPF form. For this test, I'll also use the StackPanel and add each color to the stack.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">foreach ($item in $color) {\n    $sdc = [System.Drawing.Color]::FromName($item)\n    #Validate the color\n    if ($sdc.IsKnownColor) {\n        # &lt;create a textbox for each color>\n        # &lt;convert color to html value>\n        # &lt;add the textbox to the stack>\n    }\n    else {\n        Write-Warning \"Cannot find $item as a System.Drawing.Color\"\n    }\n}<\/code><\/pre>\n\n\n\n<p>As I was working on this, I realized I needed to handle situations where I entered an incorrect color. The FromName() method will always work, even with a value like 'foo'. But in that case, the IsKnownColor value will be False. Here's the complete sample function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Show-SelectedColor {\n# sample usage: Show-SelectedColor green,chartreuse,yellow,violet,darkorange\n    [CmdletBinding()]\n    Param(\n        [Parameter(\n            Position = 0,\n            Mandatory,\n            HelpMessage = \"Enter between 1 and 10 System.Drawing.Color names\"\n        )]\n        [ValidateCount(1, 10)]\n        [ValidatePattern(\"^\\w+$\")]\n        [string[]]$Color\n    )\n\n    $form = New-Object System.Windows.Window\n    $form.Title = \"Color Sample\"\n    $form.Height = 100\n    $form.Width = 300\n    $form.top = 200\n    $form.left = 100\n    $form.UseLayoutRounding = $True\n    $form.WindowStartupLocation = \"CenterScreen\"\n    $form.SizeToContent = \"Height\"\n\n    $stack = New-Object System.Windows.Controls.StackPanel\n\n    foreach ($item in $color) {\n        $sdc = [System.Drawing.Color]::FromName($item)\n        #Validate the color\n        if ($sdc.IsKnownColor) {\n            #create a textbox for each color\n            $TextBox = New-Object System.Windows.Controls.TextBox\n            $TextBox.Width = 275\n            $textbox.Height = 30\n            $TextBox.HorizontalAlignment = \"Center\"\n            $textbox.TextAlignment = \"center\"\n            $textbox.VerticalContentAlignment = \"center\"\n            $textbox.FontSize = 16\n            #The drawing color may need to be converted to a brush color\n            #convert color to html value\n            $htmlcode = \"#{0:X2}{1:X}{2:X2}\" -f $sdc.r, $sdc.g, $sdc.b\n            $textbox.background = [System.Windows.Media.BrushConverter]::new().ConvertFromString($htmlcode)\n            $TextBox.Text = \"$($sdc.name) ($($sdc.R),$($sdc.G),$($sdc.B))\"\n            #add the textbox to the stack\n            $stack.AddChild($TextBox)\n        }\n        else {\n            Write-Warning \"Cannot find $item as a System.Drawing.Color\"\n        }\n    }\n    $form.AddChild($stack)\n    [void]$form.ShowDialog()\n\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-selectedcolor.png\"><img loading=\"lazy\" decoding=\"async\" width=\"286\" height=\"182\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-selectedcolor.png\" alt=\"show selected colors in a WPF stack\" class=\"wp-image-8878\"\/><\/a><\/figure>\n\n\n\n<p>I now have a general structure for my final project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"adding-a-wpf-grid\">Adding a WPF Grid<\/h2>\n\n\n\n<p>While using the StackPanel is easy, I knew I didn't want to have a stack of 134 layers. I envisioned multiple rows of 3 columns each. But, I also wanted this to be dynamic. I wanted the form to adjust to the number of specified colors automatically. I also intend for the function to accept wildcards and regex patterns, because why not?!<\/p>\n\n\n\n<p>Now things get tricky. For this type of layout, I need to use a Grid control instead of a StackPanel.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$grid = New-Object system.windows.Controls.Grid<\/code><\/pre>\n\n\n\n<p>Within the grid, I need to define rows and columns. I can calculate the maximum number of rows I'll need by dividing the number of colors by 3. However, I need to consider edge cases where I might have 2 or 4 colors.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">switch ($data.count ) {\n    { $_ -eq 0 } { Write-Warning \"No color values found.\" ; Return }\n    { $_ -le 2 } { $maxRows = 1 ; Break }\n    { $_ -le 5 } { $maxRows = 2 ; Break }\n    Default { $maxRows = $data.count \/ 3 -as [int] }\n}<\/code><\/pre>\n\n\n\n<p>With this information, I can create rows and columns and add them to the grid.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">for ($i = 0; $i -lt $maxRows; $i++) {\n    $row = New-Object System.Windows.Controls.RowDefinition\n    $row.Height = 30\n    $grid.RowDefinitions.add($row)\n}\n  \nfor ($i = 0; $i -lt 3; $i++) {\n    $col = New-Object System.Windows.Controls.ColumnDefinition\n    $col.Width = 300\n    $grid.ColumnDefinitions.Add($col)\n}\n<\/code><\/pre>\n\n\n\n<p>I can use the same type of ForEach enumeration to create a text box for each color. But now, I hit an obstacle. I need to position each text box in a row and column combination. When using XAML, the layout is handled like this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"xml\" class=\"language-xml\">&lt;TextBox x:Name=\"textComputername\" Grid.Column=\"1\" HorizontalAlignment=\"Left\" Height=\"20\"\nMargin=\"20,3,0,0\" TextWrapping=\"Wrap\" Text=\"\" VerticalAlignment=\"Top\" Width=\"170\"  ToolTip=\"Enter a\ncomputername or a comma separated list\" TabIndex=\"0\"\/><\/code><\/pre>\n\n\n\n<p>In this XAML snippet from another project, the TextBox is placed in grid column 1. But I'm not using XAML.<\/p>\n\n\n\n<p>I know I'll need to keep track of my position, so I'll initialize some counters for the row and column.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$r = 0 #row index\n$c = 0 #column index<\/code><\/pre>\n\n\n\n<p>Unfortunately, it isn't as simple as $textbox.grid.column.row = $r. Instead, this relies on a WPF construct known as a DependencyProperty. WPF controls have a SetValue() method that accomplish this task.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/setvalue.png\"><img loading=\"lazy\" decoding=\"async\" width=\"795\" height=\"116\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/setvalue.png\" alt=\"\" class=\"wp-image-8879\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/setvalue.png 795w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/setvalue-300x44.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/setvalue-768x112.png 768w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/figure>\n\n\n\n<p>This took quite a bit of research, headbanging, and minor curse words to get my head wrapped around. Eventually, I found some code from the ShowUI module, which helped me understand. The dependency properties will be $grid.row and $grid.column. Although, I don't reference my variables, like $grid. Instead, I use a reference to the Grid class and the desired property.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/dependencyproperty.png\"><img loading=\"lazy\" decoding=\"async\" width=\"679\" height=\"234\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/dependencyproperty.png\" alt=\"\" class=\"wp-image-8880\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/dependencyproperty.png 679w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/dependencyproperty-300x103.png 300w\" sizes=\"auto, (max-width: 679px) 100vw, 679px\" \/><\/a><\/figure>\n\n\n\n<p>As I create each textbox, I can \"place\" it in the correct row and column.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$textbox.SetValue([system.windows.controls.grid]::rowproperty, $r)\n$textbox.SetValue([system.windows.controls.grid]::columnproperty, $c)<\/code><\/pre>\n\n\n\n<p>The last bit of row and column management is to keep track of and move to the next row after three columns.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$c++\n$grid.AddChild($TextBox)\nif ($c -eq 3) {\n    $c = 0\n    $r++\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"scrolling\">Scrolling<\/h2>\n\n\n\n<p>Next, I needed to consider how the form would be displayed. I didn't want a huge form. After some testing, I realized that if there were fifteen for fewer rows, I could have the form auto-size itself.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">if ($maxRows -le 15) {\n    $form.SizeToContent = \"Height\"\n}<\/code><\/pre>\n\n\n\n<p>Otherwise, I wanted a defined window size and the ability to scroll the contents. But this isn't as simple as enabling scroll bars on the form. Think of WPF as a set of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Matryoshka_doll\" target=\"_blank\" rel=\"noreferrer noopener\">Russian nesting dolls.<\/a> There is a separate control for scrolling.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$scroll = New-Object System.Windows.Controls.ScrollViewer\n$scroll.VerticalScrollBarVisibility = \"Visible\"\n$scroll.HorizontalScrollBarVisibility = \"Auto\"<\/code><\/pre>\n\n\n\n<p>Once the grid is complete, I can add it to the ScrollViwer and then add the ScrollViewer to the form.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$scroll.AddChild($grid)\n$form.AddChild($scroll)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"processing-names\">Processing Names<\/h2>\n\n\n\n<p>The last piece of my code dealt with color names. I wanted the default behavior to show all [System.Drawing.Color] values. But I also wanted to be able to specify individual colors by name, including a wildcard, such as \"azure\",\"dark*\",\"violet\". Then I realized, why limit myself to simple wildcards? Why not support a full regex pattern like \"(green)|(blue).\" <\/p>\n\n\n\n<p>The functions Name parameter is defined to accept an array of strings that can include the wildcard character. I also decided to add a qualifier parameter called \"Regex,\" which would indicate treating the Name parameter value as a regular expression pattern.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Param(\n    [Parameter(\n        Position = 0,\n        ValueFromPipelineByPropertyName,\n        HelpMessage = \"Specify a System.Drawing.Color name. Wildcards are permitted.\"\n    )]\n    [ValidateNotNullOrEmpty()]\n    [string[]]$Name,\n    [Parameter(HelpMessage = \"Treat the Name paramter value as a regex pattern\")]\n    [switch]$Regex\n)<\/code><\/pre>\n\n\n\n<p>The Name parameter can take pipeline input by property name. I thought I might want to pipe results from my <a href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8853\/friday-fun-painting-a-pretty-picture-with-powershell\/\">Get-DrawingColor<\/a> function to this one. This means my function will have a Begin, Process, and End scriptblock. <\/p>\n\n\n\n<p>In the Begin scriptblock, I'll define a generic list that will be updated in the Process block.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$data = [System.Collections.Generic.list[string]]::New()<\/code><\/pre>\n\n\n\n<p>In the Process block, if there is a value for the Name parameter and the use specified -Regex, PowerShell will search through a list of [System.Drawing.Color] values created in the Begin block for matching values. If a name was specified without -Regex, I'll search the same list using the -Like operator. I could have combined these steps, but that would have added complexity to the code. If the user doesn't specify any name value, then I'll use the list of all colors previously generated.<\/p>\n\n\n\n<p>The Process block is doing nothing but building a list. I'll put my code to create the textboxes in the End scriptblock and show the form.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"show-colorpalette\">Show-ColorPalette<\/h2>\n\n\n\n<p>Here's the final PowerShell function. I've used Write-Verbose to provide feedback on each step of the process.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Show-ColorPalette {\n    [CmdletBinding()]\n    Param(\n        [Parameter(\n            Position = 0,\n            ValueFromPipelineByPropertyName,\n            HelpMessage = \"Specify a System.Drawing.Color name. Wildcards are permitted.\"\n        )]\n        [ValidateNotNullOrEmpty()]\n        [string[]]$Name,\n        [Parameter(HelpMessage = \"Treat the Name paramter value as a regex pattern\")]\n        [switch]$Regex\n    )\n\n    Begin {\n        Write-Verbose \"Starting $($MyInvocation.MyCommand)\"\n        #get all valid color names\n        $all = ([system.drawing.color].GetProperties().name).Where({ $_ -notmatch \"^\\bIs|Name|[RGBA]\\b\" })\n        if ($Regex) {\n            Write-Verbose \"Using Regex name matching\"\n        }\n        Write-Verbose \"Creating Form\"\n\n        $form = New-Object System.Windows.Window\n        $form.Title = \"Color Samples\"\n        $form.Height = 500\n        $form.Width = 940\n        $form.top = 200\n        $form.left = 100\n        $form.UseLayoutRounding = $True\n        $form.WindowStartupLocation = \"CenterScreen\"\n\n        Write-Verbose \"Creating Scrollviewer\"\n        $scroll = New-Object System.Windows.Controls.ScrollViewer\n        $scroll.VerticalScrollBarVisibility = \"Visible\"\n        $scroll.HorizontalScrollBarVisibility = \"Auto\"\n\n        Write-Verbose \"Creating Grid\"\n        $grid = New-Object system.windows.Controls.Grid\n        #enable grid lines for testing and troubleshooting\n        $grid.ShowGridLines = $False\n\n        #initialize a collection to hold color names from pipeline\n        #or parameter value\n        $data = [System.Collections.Generic.list[string]]::New()\n\n    } #Begin\n    Process {\n        Write-Verbose \"Using these PSBoundparameters\"\n        Write-Verbose ($PSBoundParameters | Out-String)\n        if ($PSBoundParameters.ContainsKey(\"Name\")) {\n            $pattern = $PSBoundParameters[\"Name\"]\n            if ($Regex) {\n                Write-Verbose \"Using Regex name matching\"\n                #search the list of all color names defined in the Begin\n                #block for regex matches\n                $all.Where({ $_ -match $pattern }) | ForEach-Object {\n                    $data.Add($_)\n                }\n            }\n            Else {\n                $Name | ForEach-Object {\n                    $find = $_\n                    #Search the list of all color names for that are \n                    #like each name. This supports wildcard searches\n                    $found = $all.where({ $_ -like \"$find\" })\n                    if ($found) {\n                        #use the value\n                        $found | Foreach-Object {$data.Add($_)}\n                    }\n                    else {\n                        Write-Warning \"Failed to find any colors that match $find.\"\n                    }\n                }\n            }\n        }\n        else {\n            #-Name was not used so use all color names\n            Write-Verbose \"Using all defined color names\"\n            $all.ForEach({ $data.Add($_) })\n        }\n    } #process\n    End {\n        Write-Verbose \"Displaying $($data.count) items\"\n        switch ($data.count ) {\n            { $_ -eq 0 } { Write-Warning \"No color values found.\" ; Return }\n            { $_ -le 2 } { $maxRows = 1 ; Break }\n            { $_ -le 5 } { $maxRows = 2 ; Break }\n            Default { $maxRows = $data.count \/ 3 -as [int] }\n        }\n        Write-Verbose \"Adding $maxRows rows\"\n        for ($i = 0; $i -lt $maxRows; $i++) {\n            $row = New-Object System.Windows.Controls.RowDefinition\n            $row.Height = 30\n            $grid.RowDefinitions.add($row)\n        }\n        Write-Verbose \"Adding columns\"\n        for ($i = 0; $i -lt 3; $i++) {\n            $col = New-Object System.Windows.Controls.ColumnDefinition\n            $col.Width = 300\n            $grid.ColumnDefinitions.Add($col)\n        }\n\n        $r = 0 #row index\n        $c = 0 #column index\n        foreach ($item in $data) {\n            $sdc = [System.Drawing.Color]::FromName($item)\n            if ($sdc.IsKnownColor) {\n                $TextBox = New-Object System.Windows.Controls.TextBox\n                $TextBox.Width = 275\n                $textbox.Height = 30\n                $TextBox.HorizontalAlignment = \"Center\"\n                $textbox.TextAlignment = \"center\"\n                $textbox.VerticalContentAlignment = \"center\"\n                $textbox.FontSize = 16\n                #The drawing color may need to be converted to a brush color\n                #convert color to html value\n                $htmlcode = \"#{0:X2}{1:X2}{2:X2}\" -f $sdc.r, $sdc.g, $sdc.b\n                Write-Verbose \"Adding $item [$htmlcode]\"\n                $textbox.background = [System.Windows.Media.BrushConverter]::new().ConvertFromString($htmlcode)\n                $TextBox.Text = \"$item ($($sdc.R),$($sdc.G),$($sdc.B))\"\n                $textbox.SetValue([system.windows.controls.grid]::rowproperty, $r)\n                $textbox.SetValue([system.windows.controls.grid]::columnproperty, $c)\n                #move to the next column\n                $c++\n                $grid.AddChild($TextBox)\n                if ($c -eq 3) {\n                    $c = 0\n                    $r++\n                }\n            }\n            else {\n                #this will probably never be called\n                Write-Warning \"Can't validate $item as a [System.Drawing.Color] value.\"\n            }\n\n        } #foreach item in data\n        Write-Verbose \"Adding child elements to the form\"\n        $scroll.AddChild($grid)\n        $form.AddChild($scroll)\n        #set the form to size to content is less than 15 rows\n        if ($maxRows -le 15) {\n            $form.SizeToContent = \"Height\"\n        }\n        Write-Verbose \"Displaying the form\"\n        #the prompt will be blocked until the form is closed\n        [void]$form.ShowDialog()\n        Write-Verbose \"Ending $($MyInvocation.MyCommand)\"\n\n    } #end\n}<\/code><\/pre>\n\n\n\n<p>I can use the function to display several colors, including using wildcards.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Show-ColorPalette -Name \"*green\",\"violet\",\"orangered\",\"skyblue\"<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/wildcard-color-display.png\"><img loading=\"lazy\" decoding=\"async\" width=\"926\" height=\"212\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/wildcard-color-display.png\" alt=\"display colors with wildcard support\" class=\"wp-image-8883\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/wildcard-color-display.png 926w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/wildcard-color-display-300x69.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/wildcard-color-display-768x176.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/wildcard-color-display-850x195.png 850w\" sizes=\"auto, (max-width: 926px) 100vw, 926px\" \/><\/a><\/figure>\n\n\n\n<p>With regular expressions.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Show-ColorPalette -Name \"(blue)|(green)\" -Regex<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-regex-color.png\"><img loading=\"lazy\" decoding=\"async\" width=\"926\" height=\"392\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-regex-color.png\" alt=\"show colors with regex\" class=\"wp-image-8884\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-regex-color.png 926w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-regex-color-300x127.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-regex-color-768x325.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-regex-color-850x360.png 850w\" sizes=\"auto, (max-width: 926px) 100vw, 926px\" \/><\/a><\/figure>\n\n\n\n<p>Or everything by default.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/all-colors-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"926\" height=\"493\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/all-colors-1.png\" alt=\"all colors\" class=\"wp-image-8885\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/all-colors-1.png 926w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/all-colors-1-300x160.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/all-colors-1-768x409.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/all-colors-1-850x453.png 850w\" sizes=\"auto, (max-width: 926px) 100vw, 926px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"summary\">Summary<\/h2>\n\n\n\n<p>I don't expect you to have a compelling business need for these functions, but that's not the point. Instead, I hope you found something valuable that you can use in your PowerShell scripting.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s continue looking at how to use PowerShell and a Windows Presentation Foundation (WPF) form to display [System.Drawing.Color] values. This article builds on an earlier post so if you missed it, take a few minutes to get caught up. As I did earlier, before running any WPF code in PowerShell, you should load the required&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New on the blog: Even more fun with #PowerShell and WPF","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8,518],"tags":[224,534,540,379],"class_list":["post-8877","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","category-wpf","tag-function","tag-powershell","tag-scripting","tag-wpf"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Even More Colorful Fun with PowerShell and WPF &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"The wrap-up on using PowerShell and WPF to display System.Drawing.Color values. Regex, scrollviewers, dependency properties and more.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Even More Colorful Fun with PowerShell and WPF &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"The wrap-up on using PowerShell and WPF to display System.Drawing.Color values. Regex, scrollviewers, dependency properties and more.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-16T17:48:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-selectedcolor.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Even More Colorful Fun with PowerShell and WPF\",\"datePublished\":\"2022-02-16T17:48:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/\"},\"wordCount\":1110,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/show-selectedcolor.png\",\"keywords\":[\"Function\",\"PowerShell\",\"Scripting\",\"WPF\"],\"articleSection\":[\"PowerShell\",\"Scripting\",\"WPF\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/\",\"name\":\"Even More Colorful Fun with PowerShell and WPF &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/show-selectedcolor.png\",\"datePublished\":\"2022-02-16T17:48:00+00:00\",\"description\":\"The wrap-up on using PowerShell and WPF to display System.Drawing.Color values. Regex, scrollviewers, dependency properties and more.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/show-selectedcolor.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/show-selectedcolor.png\",\"width\":286,\"height\":182},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8877\\\/even-more-colorful-fun-with-powershell-and-wpf\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Even More Colorful Fun with PowerShell and WPF\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Even More Colorful Fun with PowerShell and WPF &#8226; The Lonely Administrator","description":"The wrap-up on using PowerShell and WPF to display System.Drawing.Color values. Regex, scrollviewers, dependency properties and more.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/","og_locale":"en_US","og_type":"article","og_title":"Even More Colorful Fun with PowerShell and WPF &#8226; The Lonely Administrator","og_description":"The wrap-up on using PowerShell and WPF to display System.Drawing.Color values. Regex, scrollviewers, dependency properties and more.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/","og_site_name":"The Lonely Administrator","article_published_time":"2022-02-16T17:48:00+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-selectedcolor.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Even More Colorful Fun with PowerShell and WPF","datePublished":"2022-02-16T17:48:00+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/"},"wordCount":1110,"commentCount":5,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-selectedcolor.png","keywords":["Function","PowerShell","Scripting","WPF"],"articleSection":["PowerShell","Scripting","WPF"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/","name":"Even More Colorful Fun with PowerShell and WPF &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-selectedcolor.png","datePublished":"2022-02-16T17:48:00+00:00","description":"The wrap-up on using PowerShell and WPF to display System.Drawing.Color values. Regex, scrollviewers, dependency properties and more.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-selectedcolor.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/show-selectedcolor.png","width":286,"height":182},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8877\/even-more-colorful-fun-with-powershell-and-wpf\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Even More Colorful Fun with PowerShell and WPF"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":8684,"url":"https:\/\/jdhitsolutions.com\/blog\/wpf\/8684\/creating-a-powershell-clock\/","url_meta":{"origin":8877,"position":0},"title":"Creating a PowerShell Clock","author":"Jeffery Hicks","date":"November 9, 2021","format":false,"excerpt":"I've published a new project to the PowerShell Gallery. This is something that I needed, and maybe you do as well. Even though I have the typical clock running in the Windows taskbar, I have an ultrawide monitor so it isn't always easy to read. I had been running the\u2026","rel":"","context":"In &quot;Scripting&quot;","block_context":{"text":"Scripting","link":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/11\/sample-2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":6035,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6035\/making-short-links-long-with-powershell-and-wpf\/","url_meta":{"origin":8877,"position":1},"title":"Making Short Links Long with PowerShell and WPF","author":"Jeffery Hicks","date":"July 9, 2018","format":false,"excerpt":"Sometimes, when I have nothing better to do, I kill some time giving Todd Klindt and Shane Young a hard time during their podcast. You should join me sometime. Anyway, during a recent show Todd mentioned a bit of PowerShell code he put together to resolve short links. You see\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/07\/image_thumb-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/07\/image_thumb-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/07\/image_thumb-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/07\/image_thumb-1.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":6879,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6879\/the-powershell-magic-8-ball\/","url_meta":{"origin":8877,"position":2},"title":"The PowerShell Magic 8 Ball","author":"Jeffery Hicks","date":"October 28, 2019","format":false,"excerpt":"[I updated this article to reflect minor changes in the code and the release of PowerShell 7. This article was originally published 28 October, 2019]. Last year I shared some PowerShell code on Twitter about this time of year. I have a short script that uses Windows Presentation Foundation (WPF)\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/10\/8balloracle-2_thumb.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/10\/8balloracle-2_thumb.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/10\/8balloracle-2_thumb.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/10\/8balloracle-2_thumb.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":8871,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8871\/more-colorful-fun-with-powershell\/","url_meta":{"origin":8877,"position":3},"title":"More Colorful Fun with PowerShell","author":"Jeffery Hicks","date":"February 14, 2022","format":false,"excerpt":"In my last Friday Fun post, I shared some PowerShell code for displaying [System.Drawing.Color] values from a console using ANSI escape sequences. After I published the article, I realized what I really wanted was a color palette display that wouldn't be affected by the console background. A Windows Presentation Foundation\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/textbox-background.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/textbox-background.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/textbox-background.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/textbox-background.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":9154,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9154\/a-wpf-countdown-timer\/","url_meta":{"origin":8877,"position":4},"title":"A WPF Countdown Timer","author":"Jeffery Hicks","date":"October 19, 2022","format":false,"excerpt":"Last year I released a PowerShell module called PSClock. The module contains a command to create a transparent WPF form displaying a clock. Shortly after, someone posted a request for a countdown timer. Not an unreasonable request and one I finally got around to implementing. However, I already had a\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"pscountdown timer","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/10\/countdowntimer.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/10\/countdowntimer.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/10\/countdowntimer.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/10\/countdowntimer.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5816,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5816\/a-powershell-input-tool\/","url_meta":{"origin":8877,"position":5},"title":"A PowerShell Input Tool","author":"Jeffery Hicks","date":"December 7, 2017","format":false,"excerpt":"In PowerShell, the primary means to get interactive input from a user is with the Read-Host cmdlet. There's nothing wrong with it but sometimes if you are using it in a graphical tool like the PowerShell ISE or VS Code you may not realize you are being prompted. Or perhaps\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-2.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=8877"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8877\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}