I just completed a PowerShell script solution for one of my college using PrimalForms 2009. Well, this give me a chance to understand SAPIEN’s new product and I have to admit… I’m impress!! I was able to create a Windows form, add my PowerShell code, test the form, and then create an executable. YES!! You read it right!! I build an executable out of my script. That’s AWESOME!!
PrimalForms 2009 come with some sample forms. But, we are going to build a simple “Hello WORLD!!” sample. All PrimalForms files has an extension of *.pff. With this tool you can build your PowerShell Windows solution then test the form directly to PowerShell Console, PrimalScript 2009, build only the script, and/or build your Executable by using the “Package” option.
While building my form I found a few things and mainly because I was depending on some of the PowerShell pre-defined variables. PowerShell variables are not use by PrimalForms when running the solution. But, to overcome this obstacle, I had to use the Environment variables to construct the value I needed.
*note: Check the link about PowerShell environment variables –http://www.microsoft.com/technet/scriptcenter/resources/pstips/dec07/pstip1214.mspx
Now, let us build our first PowerShell “Hello World!!” executable application:
1. Open PrimalForms 2009, and click on “New”, then “New Form”
2. Use the mouse to expand the form to the right, and add a label object from the Toolbox by dragging the object to the form.
3. Now on the left in the “Properties” panel, we are going to “Label1” font size to “30”, expand the label box, and leave the text “label1”.
4. Now, we are going to add a Button object so add the PowerShell code to it to display the “Hello World!!!” text. So, from the Toolbox select and drag the Button to the form and change the text to OK.
*** Tip: Double-Click on the toolbox object and it will added to the form automatically ***
5. Now we are ready to add some code to our Button. We do this by double-clicking on the Button object and it will take us to the Scripting section of the form. Then, let’s add the code.
As you can see, PrimalForms provide you with intellisense when building your code.
6. Now we can proceed to test our PowerShell “Hello World” solution by selecting one of the following options: (I’m going to pick “Run” and it will ask you to save the form.)
Then, click “OK” button.
7. Ok, now we have a PowerShell "Hello World" application and I want create an executable from my script. This is done by selecting the menu option “Package”. Under the “Package” you have two other option available: “Package and Run” and “Package and Open Folder”.
8. Using “Package and Open Folder” give me the chance to see the file and move it somewhere else. I’m going to briefly tell you that this option will let you build the package for either 32bit or 64bit machines. THAT IS SWEET!!
Just pick the Platform of your choice and press the “Build” button.
9. Then, your package solution will be stored under “C:\Users\Max\Documents\SAPIEN\Script Packages” folder.
Is this a great solution if you want to build an executable from your PowerShell scripts?? I think it is.
Although, you can get PrimalForms 2009 as a standalone or there’s a Community version, my recommendation is to get it with PrimalScript 2009 or the best deal with software bundle package “PrimalScript 2009 Studio”- this is the best deal for the money.
Thanks SAPIEN Technologies for all the great products!!
For more information on SAPIEN’s products: http://www.primaltools.com/products/info.asp?p=SoftwareBundles