Creating GUIs for your scripts can be a tedious process. That is why I don’t do so for each powershell project I release. Instead of wasting my precious little free time putting together yet another GUI for a one off script I decided to create a tool which will create the GUI scripts for me automatically!
This tool will parse a function or file with parameter elements and automatically generate a basic form with all the controls needed to generate the input for the function. This first release supports string (textbox), switch/bool (checkbox), and string with validateset defined (combobox). For many of my own functions and projects this is more than adequate.
I’ve also included a little mini project which resembles the output form from out-gridview (which I’m certain many are familiar with). Unfortunately Out-GridView requires the ISE be installed on whichever host you are running scripts on. The additional function I’ve included is called Out-GridViewForm and it gets around that requirement while still offering an easy way to view the array of psobjects which many scripts will spit out as their results. (I added an export to CSV button to this for kicks).
As I put this together on a marathon hacking session with bleary eyes deep in to the darkness of the midnight hours there are bound to be issues with this first release. If you review the code please be kind to me. There are areas where I’m not using the most elegant techniques but it seems to get the goal accomplished so I’m not entirely unhappy with the results. Here are some general usage notes:
- To get the best results from this script you will want to use a fully configured parameter block for your script with defined help messages and default values. A sample function which gathers the top 10 processes running by CPU utilization has been included for your convenience.
- The code does its best to differentiate between a fully formed function block and a script file with parameters. In the cases where you use a file that is not a self contained function it will automatically create a GUI wrapper which tries to call the script file directly so file paths are important if you are looking for portability.
- As always, I wrote this mainly to scratch an itch of my own (I use almost every script I write) and have released it to the community to give a little bit back. I welcome feedback of any kind as it motivates me to keep releasing more.
You can get a zip of the PowerShell Studio 2012 project, a build of the executable, an export of the project as a single powershell script, and a few example input functions from the Microsoft Technet Gallery.