SAPIEN PowerShell Studio GUI Simplicity

In my last blog I show how easy it is to use a template to build a simple GUI application with a datagrid. Then, we enabled one of the sample code with the Script section of the “Load” button in order the process and display the results. And, this was just a start!

sapienstudio_00_2016-11-11_14-44-34

Simplicity

Now, how about making the GUI more functional so you can type any PowerShell command and the provide the results in the datagrid pane.
We can use the same GUI application we build and add a text box to be use to type our command.

sapiendgsimply_01_2016-11-14_14-14-52

Then, we need to add the following snippet code in the “Load” button script section:

$scriptblock = $executioncontext.invokecommand.NewScriptBlock($textbox1.Text);
$MyGridObject = $null; $MyGridObject = Invoke-Command -Scriptblock $scriptblock;
Load-DataGridView -DataGridView $datagridviewResults -Item $MyGridObject -AutoSizeColumns DisplayedCells;

sapiendgsimply_02_2016-11-14_14-14-52

So, after adding both the Text box and the PowerShell code, we got ourselves a function GUI that can run your PowerShell script and display the results on the datagridview. By typing the following one-liner then press the “Load” button:

$d = Dir -file; $d | Select Name, length, directory;

sapiendgsimply_03_2016-11-14_14-14-52

And, this is just out of the box UX with little customization.

Next Step

Now, you won’t be able to run the PowerShell GUI application outside of PowerShell Studio. The next step will be to create an executable GUI application with the following steps from the menu:

1. Go to the Deploy menu, and click on “Settings“.

sapiendgsimply_04_2016-11-14_14-14-52

2. In the “Engine Settings” , you make necessary changes to the application information.

sapiendgsimply_05_2016-11-14_14-14-52

3. Under “Execution Restrictions“, you can identify which environments can execute this application.

sapiendgsimply_06_2016-11-14_14-14-52

4. In “Version Information“, you can provide useful information for source control.

sapiendgsimply_07_2016-11-14_14-14-52

5. Finally, “Build Options“, in case you need some provide either Pre or Post commands during the build on this application.

sapiendgsimply_08_2016-11-14_14-14-52

6. *Now you can click either execute “Build” or “Build & Run” to create the executable.

sapiendgsimply_10_2016-11-14_14-14-52

*Note: The executable will be stored on the same folder you had created the application.

sapiendgsimply_09_2016-11-14_14-14-52

For more information

Download the product for a evaluation:
https://www.sapien.com/software/powershell_studio

More information about PowerShell Studio:
https://www.sapien.com/assets/pdf/PowerShell_STUDIO.pdf

This how simple it is to create a PowerShell executable GUI (also non-GUI) application in PowerShell Studio.

Next blog I’ll be covering buidling the MSI installer for this application.

This entry was posted in PowerShell. Bookmark the permalink.