If you were at this year's TechEd event in New Orleans, I hoped you dropped by the SAPIEN Technologies booth and picked up your free Scripting Toolkit. What's that you say? Check it out on the SAPIEN blog and then download your free copy.
During the last TechMentor conference in Orlando, deployment MVP and guru (I want to call her a deployment diva but I don’t want people to get the wrong idea. Think “diva” in the star sense without the ego and entourage,) Rhonda Layfield asked me to look at some PowerShell code. She was trying to make sense of code cobbled together from the Microsoft Deployment Toolkit to create a deployment share. I’m not much on deployment technologies these days (I miss the RIS days), but PowerShell I know.
Eventually we ended up with a more coherent and usable script. Of course, since I’m always looking for something extra, I thought this would make a great basis for a WinForms script. There are a lot of pieces to this puzzle so a form-based wizard seemed like a good idea. The end result is DeploymentWizard.ps1.
If you are familiar with the deployment toolkit then I expect you’ll know how to fill in the blanks. If not, I’ve used a ToolTip control in the form to provide popup help when you hover your mouse over a field.
After you complete the form, click Build It and the deployment share will be created along with the task sequence. All of the MDT cmdlets are executed using –verbose so you can keep track. Expect the script to need several minutes to complete. When finished, you should see a new share in the MDT management console.
The only caveat is that you need to run the script in an elevated session. If you have deployment questions or needs, I encourage you to contact Rhonda via her web site, http://www.deploymentdr.com. The official name is “Deployment Done Right”, but I also look at the link as “deployment doctor” which works just as well.
If you have PowerShell-related problems with the script, let me know. I have limited resources for testing so I can’t guarantee you won’t run into something.
I used SAPIEN’s PrimalForms 2009 to develop the form and script. The source PFF file is included in the download zip file if you are interested in modifying the form. Otherwise, edit the PS1 file as necessary.
Let me know how this works out for you.
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.
I know there was some concern related to my departure from SAPIEN about the status of the Windows PowerShell: TFM book. You’ll be happy to know that Don Jones and I are both involved now in the final revisions. SAPIEN is very committed to this project and supporting the PowerShell community and I’m very happy that this book will finally make it onto your bookshelf.
No official word on final publication but I think we’d all like it to be available by the time PowerShell v2.0 ships with WIndows 7 this fall.
Stay tuned to this blog for more details.
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.
Even though PowerShell is by design a console based management tool, there are instances where you would like to use a GUI. PowerShell can use the Windows forms classes from the .NET Framework. However in the past creating anything other than the simplest of forms was very tedious and time consuming. Now SAPIEN Technologies has a free solution. Download the free PrimalForms tool and use a WYSIWYG form editor. Drag and drop controls, configure them and define events such as Click and SelectionChanged. PrimalForms will generate a PowerShell script to create the form. All you have to do is refine it, add your PowerShell code to react to the events, test and deploy!