Click here to Skip to main content
15,662,484 members
Articles / Programming Languages / PowerShell
Posted 7 May 2014

Tagged as


6 bookmarked

A PowerShell Form Generator

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
7 May 2014CPOL2 min read
A PowerShell 3.0 Form Generator.

Image 1


This script show a simple and preliminary Form Generator for PowerShell, developed with 3.0 version.

Using the program

The script contains a function formgen which needs a fields description in order to start and other non mandatory parameters:
  • widgets a mandatory string containing the fields description;
  • title a possibly string which is the title in the form;
  • caption a possibly string which is the caption form.
$parm = "Psw,psw,txt password;cmb,combo,,,g,a:alfa|beta|g:gamma|delta;list,combo2,,25,,a:aleph|bet|g:gimel|dalet"
$parm += ";Chk,check,Check box,,"
.\formgenbase.ps1 -widgets $parm -title "Try Form Generator"
Every widget description is characterized by a list of attributes (comma separated) in this order:
Type, Field Name, Field Label, Length, Default Value and Extra. Every description is separated by semicolon:
  • Type is the widget type, they are for now, five types: text, password, list, combo box and check box.
  • Name the widget name.
  • Label the widget label.
  • Length the widget length.
  • Default the possible default value.
  • Extra an extra field for add information to the widget, (this depends on the type).
The program inserts three buttons: Ok, Reset and Cancel, but if there is only one list widget, no buttons are presents because the choice on item exits the form.

Closing the form, the global variable $fg_data, an hash table where the key is the widget name, contains the input inserted plus a key fg_button whit the name of the button clicked.

There are no particular things to tell for widget type Text, password or check box. The data for the items of Lists and Combos are contained in the extra field each separated by the character |; every item can have a possible key, which is returned if the item is selected; the syntax is: key:value; if one would propose an item by default, the key or the value must be inserted in the default field.


If the cancel button was pressed or the form is closed in the menu bar, there is only fg_button element.

Use $host to determine the PowerShell engine version.

Maybe in the future

First the software needs of an event handler for personalize the widgets or to add controls. Also may add some controls like mandatory fields, mail check etc. The script lacks of important widgets like slider, numeric fields, radio button, file dialogue, date and time...


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer Condor Informatique
Italy Italy
Computer literacy (software) : Languages: PHP, Javascript, SQL Autoit,Basic4Android; Frameworks: JOOMLA!
Teaching/Training skills on Office, WEB site development and programming languages.
Others : WEB site development.
UNDP Missions
feb – may 2003 Congo DR Bukavu: ground IT computer course
nov 2003 Burundi Bujumbura: Oracle Data Base course
feb 2005 Burundi Bujumbura: JAVA course
mar 2005 Mali Kati: MS Office course
oct 2006 Mali Kati: MS Office course
jun 2006 Burkina Faso Bobo Dioulasso: MS Office course
jun 2007 Burkina Faso Bobo Dioulasso: MS Office course
may 2007 Argentina Olavarria hospital: Internet application for access to medical records
apr 2008 Burkina Faso Ouagadougou: MS ACCESS and dynamic Internet applications
jun 2008 Niger Niamey: analysis of the computing needs of the Niamey hospital
may 2009 Burkina Faso Ouagadougou: MS ACCESS and dynamic Internet applications
oct 2010 Niger Niamey: analysis of the computing needs of the Niamey hospital (following)
Region Piedmont project Evaluation
mar 2006 Burkina Faso, Niger
mar 2007 Benin, Burkina Faso, Niger
sep 2008 Benin, Burkina Faso, Niger
feb 2010 Burundi Kiremba hospital: MS Office course
feb 2011 Congo DR Kampene hospital: MS Office course

Comments and Discussions

GeneralMy vote of 5 Pin
@k@ ?26-Jul-14 3:35
professional@k@ ?26-Jul-14 3:35 
GeneralRe: My vote of 5 Pin
Member 420697426-Jul-14 4:40
Member 420697426-Jul-14 4:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.