Using Windows Forms controls in PowerShell is a tricky thing, because it only supports very simple event handling. However, some time ago I wrote a Snap-In to allow anyone to work with .NET events, even asynchronous ones. You can download it from my PSEventing CodePlex project; it comes with full help via the normal PowerShell mechanisms of -? and get-help. Examples are also available online on how to use the project for more complex scenarios. Here's simple demonstration of autogenerating a listbox control filled with choices given as arguments to a simple script:
And here is the source to the get-choice.ps1 script itself. This requires PSEventing 1.0 or 1.1 Beta.
Page rendered at Friday, August 29, 2008 3:57:31 AM (Eastern Standard Time, UTC-05:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.