I stumbled upon this epic .net project by PhonicUK on Github for “an event-driven windowing system using a line-art interface for use by command-line applications” and thought I would see if it worked in PowerShell. The results, I think are pretty cool!

The code to create this is really very similar to WinForms style of coding and can be generated very quickly. I will give a short walkthrough on how to create a GUI using this sweet library.

How to make the magic happen

The Series

Okay, so about 5 months ago I wrote a blog post on a potential method of executing PowerShell from a user interface built in HTML and javascript. It turns out that the series was one of the more popular ones I have posted and it consistently receives traffic.

The Problem

I did not really love my other method. It was just the only method I had found. The problems were:

  • Complex to learn (build a server, build a client, learn HTTP methods)
  • Possible security concerns (even though we were only listening on localhost a user could potentially gain access to another user session and execute code as a different user)

This is just going to be a quick tip but I have not posted in awhile and thought I would share this little quick hit. PowerShell has a SUPER useful command for rendering variables in PowerShell into HTML called ConvertTo-HTML and of course HTML in general is really easy to spice up a bit as far as the looks go.

How can we show that information to an end user in a pop-up?

Since PowerShell has full .NET access we can pass an HTML string into an embedded WPF WebBrowser?

The Series

If you have been following along with the previous two parts to this blog, I know what you have been saying. When will we get to the GUI part! Everything up to this point has been all web servers and web technology. Which could come in handy but we just want to make a simple GUI in HTML that runs PowerShell. The browser thing is cool but you don’t want to pop open a browser every time you want to run some scripts. Integrating that into the pipeline would be difficult too right?

Today, we finally get to the good stuff!

The Series

More boring stuff today. We are going to cover how to handle URLs in this PowerShell web server thingy and covering handling query strings. Stick with me on this though! I promise we will get to the good stuff soon.