In this article I’ll give you a short demo how easy it is to create a PowerShell user interface with the free PrimalForms from Sapien. At the 4th of November Sapien released their first public version of PrimalForms. Jeffery Hicks over at Sapien reports :
I hope you are as excited about the release of PrimalForms as I am. In the past creating a Windows form in PowerShell was a very tedious task and one I rarely used except for the most simplest of forms. No more. The free PrimalForms tool lets me create a very rich Windows form using a WYSIWYG editor. I can export the form to a file, add my PowerShell code and call it a day.
First download PrimalForms at Sapien’s the free tools section. After installing, you just create a wonderful user interface and copy the PowerShell script code to your clipboard.
In this example I created a button and a multiline text field. I copied my code to the PowerGui script editor and added a few lines of my own code. The following two lines are added to the top of the script.
Get-PSSnapin -registered | Add-PSSnapin -passthru -ErrorAction SilentlyContinue
$Server = Connect-VIServer -Server 192.168.75.128 -User root -Password vmware
When you walk through the script you’ll see the sections where you can add your own code. In this example I added the following code under the button.
#Provide Custom Code for events specified in PrimalForms.
$button1_OnClick=
{
#TODO: Place custom script here
$textBox1.text = Get-VM
}
And here’s the result.