Recently, I posted an entry on how to ping an IP subnet with PowerShell. Using objects in the PowerShell pipeline is a good thing. But sometimes we want a GUI and I figured the ping subnet script would make a good WinForm script. Continue reading
My December Mr. Roboto column is now online This month’s tool is a PowerShell WinForm script that uses WMI to compress files. I used PrimalForms 2009 to build the graphical interface. The interface is essentially a wizard that lets you build a WMI query to find files and compress them.
Results can be logged to a CSV file or you can merely list the files that match the search criteria. Here’s a code excerpt.
The script has (I think) a nice example of providing popup help. Download SearchSqueeze.zip
Thanks to Wes Stahler for being such a willing lab rat.
I’ve been doing some work lately in the newest version of SAPIEN’s PrimalForms 2009. I like to make my scripts as user friendly as possible without forcing someone to read lengthy and boring documentation. One technique that I’ve started using is to use a ToolTip control and offer a short description or instruction when the mouse hovers over a control. Let me show you. This techinque should also work with the free PrimalForms Community Edition, although you’ll need to take a few extra steps to add the necessary code.
SAPIEN’s Primal Forms 2009 now has an integrated script editor that you can use as a standalone editor for PowerShell scripts. The app has integrated help, popup command help, a PowerShell browser, a .NET object browser. As you can see in the screen shot I’ve started a very basic PowerShell script.
Once saved, I can run the script and view the results in the output panel. You can open and edit existing scripts as well. If you want a more full featured editing experience with code samples, snippets and more, or if you still need to work in other languages like VBScript, you’ll want PrimalScript 2009. But let’s say you only require an easy to use PowerShell script editor that provides a Windows Form feature, then PrimalForms 2009 is the ticket.
One thing I think you’ll like is the ability to package the script as an EXE. PowerShell still needs to be installed on any computer where you will be running the package. When you package the script, you define a package name, the platform, an icon and a manifest, if required. In the platform drop down select either 32 or 64 bit Windows. Depending on what your script is doing you may need to pick a commandline platform. Otherwise, any object written to the pipeline will be displayed in a dialog box which is probably not the experience you were expecting.
You can package your script with alternate credentials as well as digitally sign the file.
On the last page you can add metadata to your packaged script. This includes information such as version numbers, a description, file names and copyright.
When you are satisfied, click Build and your script will be packaged into an EXE. I love the idea of packaging my scripts. The content is protected and can’t be modified. Of course, the primary purpose for PrimalForms is to create a forms based PowerShell script which you can package following the same guidelines I just explained.
You can read more about the latest PrimalForms 2009 version on the SAPIEN blog.
SAPIEN Technologies finally released PrimalForms 2009. If you have any sort of requirement to create a graphical interface to your PowerShell script, this is the tool to get. SAPIEN will continue to offer the free community version of Primal Forms from their community tools page.
PrimalForms 2009 includes these features:
- Visually build sophisticated Windows forms in Powershell without having to write any code.
- Integrated Powershell Script Editor with syntax coloring, PrimalSense, bookmarks and code folding.
- Import .NET assemblies for expanded PrimalSense.
- Integrated Powershell Help and Snapin support.
- Integrated .NET Object Browser.
- Export your scripts to a file or clipboard.
- Package your scripts into an executable supporting 32 and 64 bit platforms.
- Run your script directly from within PrimalForms 2009.
- Ability to preview your Forms without executing your script code.
- Round trip code generation preserves your code between editing sessions.
Whenever I teach about PowerShell and Windows Forms based scripts, this is the tool I use because it is so easy and lets you focus on PowerShell scripting instead of figuring out PowerShell code to configure the graphical elements.
PrimalForms 2009 is available as a stand alone product which you can download and try for 45 days or buy a license from ScriptingOutpost.com. SAPIEN is even offering the app at 40% off as a way of introducing it into the community. If you have a PrimalScript 2009 Studio license, you will get PrimalForms for free.
When you download and try out PrimalForms, be sure to look through the Getting Started section of the help guide. You’ll also get a number of sample forms and scripts to help get you going on the right track.
I love this tool and have plans for a number of graphical PowerShell scripts over the next several months.