Skip to content

About Forms

In a ScriptoForm, the form is the fundamental component of the PowerShell script. It is the interface the user interacts with and controls the lifespan of the script. It is based on Windows Forms built with standard .NET assemblies and is instantiated and displayed when the script starts. When the user closes the form, the script exits. While the form is displayed, the script is idle waiting for the user to interact with it to perform one or more actions that you include as part of the design.

The typical lifespan of a ScriptoForm is as such:

  1. The user launches the ScriptoForm PowerShell script - either natively or as a compiled executable.
  2. The script will perform any actions you have included in the design prior to showing the form. This might include, for example, establishing an initial connection to a remote resource such as VMware vCenter or Office 365.
  3. The form is instantiated and displayed to the user. If configured, the form will perform any “OnLoad” or “OnShown” Event Handlers you have included in the design. This might include, for example, populating a drop-down list with values from an external source or an array in the script file.
  4. The user interacts with the form using the controls you have provided and the script performs the actions based on the event handlers and fuctions you have provided in the design. The form provides feedback to the user, as needed, by updating controls, utilizing components such as Error Providers, and displaying MessageBox modal dialog boxes.
  5. When finished, the user closes the form (typically by clicking a “Close” button on the form) and the script exits. If configured, the script will perform any cleanup tasks that you have included in the design after the form has closed before exiting the script. This might include, for example, clearing senstive variables or closing sessions to remote resources.
  6. If the script is running from a compiled executable, the executable will terminate once the script has exited.
By default, a ScriptoForm includes only one form, known as $FormMain (the “main” form). However, it is possible to include multiple forms in the script that are instantiated and displayed as needed as the user interacts with the main form throughout its lifespan.