Skip to content

Build a ScriptoForm

This guide leads you through building your first ScriptoForm. This guide assumes you have some general familiarity with using PowerShell and PowerShell modules. In this example, a new ScriptoForm project is built with the following parameters:

  • Form size: Medium
  • Coding style: Allman
  • Project location: D:\Demo
  • Project name: Show-DemoForm
  1. Open a PowerShell console. Windows Terminal is recommended.

  2. First Time Only!

    Install the SmartAceDesigns.ScriptoFormTemplates PowerShell module from the PowerShell Gallery:

    PowerShell
    Install-Module -Name SmartAceDesigns.ScriptoFormTemplates
  3. First Time Only!

    Install the Plaster PowerShell module from the PowerShell Gallery:

    PowerShell
    Install-Module -Name Plaster
  4. Run the following command from the PowerShell console:

    PowerShell
    New-SADScriptoFormProject -Size Medium -DestinationPath D:\Demo -Name Show-DemoForm
  5. Done! You can now use your favorite code editor such as VS Code or PowerShell ISE to customize the Show-DemoForm.ps1 script file. By default the new project directory will open in VS Code if it is detected on your system.

For an overview of the directories and files created in your new project directory, and their purpose, check out the Project Structure article.

Use the following steps as guidelines to help customize the files in the new ScriptoForm project folder after deployment:

  1. Script File
    • Add general notes to the top comments section.
    • Add global settings, constants, and support file references to the Settings region. Remove the temporary reminder comments.
    • Add additional form controls to the Controls region. Remove the temporary reminder comments.
    • Add control properties and handlers to the $ShowMainForm script block in the Forms region for any new controls you added. Remove the temporary reminder comments.
    • Add custom functions to the Functions region. Remove the temporary reminder comments or remove the entire region if unused.
    • Add additional control event handler definitions to the Handlers region for any new controls you added. Remove the temporary reminder comments.
    • Add script functionality, exception handling, and control reset code to the $ButtonRun_Click script block in the Handlers region. Remove the temporary reminder comments.
  2. README File
    • Add content to the Purpose region.
  3. Project Folder
    • Add additional support files referenced by the PowerShell script to the folder.
  4. CSPROJ File
    • Add an <EmbeddedResource> sub-element, for each support file referenced by the PowerShell script, to the <ItemGroup> element.
  5. Optional: Build Folder
    • Add a custom icon file to the folder if the default icon is unsuitable.
  6. Optional: CSPROJ File
    • Add the custom icon filename to the <ApplicationIcon> element if the default icon is unsuitable.