#
ScriptSelector.ps1
#
Table of Contents
Table of Contents Purpose Dependencies Function Usage Inputs Variables Command Line Flags Outputs Notes
#
Purpose
Provides an interactive Windows Forms menu to select and launch common PowerShell scripts, with user-friendly feedback and error handling.
Needs a future enhancement to be able to specify if a script should run in PowerShell 7, and if so - launch the script in it.
#
Dependencies
#
Function
- Displays a Windows Forms GUI with a numbered list of available scripts (from a configurable array).
- Allows the user to select a script and click "Run" to execute it.
- Launches the selected script in a new PowerShell process, waits for completion, and checks the exit code.
- Future enhancement: Allow a script to be launched directly in PowerShell 7 if needed.
- Provides user feedback via pop-up messages for success, error, or cancellation.
- Handles missing script files and displays an error if not found.
- Automatically numbers menu items based on their order in the array.
#
Usage
Run directly to launch the menu:
./ScriptSelector.ps1
#
Inputs
- User selection via the GUI menu (list box and button click).
#
Variables
$form
,$listBox
,$runButton
: Windows Forms controls for the menu and actions.$scriptBasePath
: Base directory for script files.$scriptInfo
: Array of script display names and file names.$scriptMapping
: Array of numbered menu items and corresponding file names.$selectedScript
,$scriptItem
,$scriptFile
,$scriptPath
: Used for script selection and execution.
#
Command Line Flags
None.
#
Outputs
- Launches the selected script in a new PowerShell process.
- Shows pop-up messages for script completion, error, or cancellation.
- Displays an error if the script file is not found.
#
Notes
- Script paths and menu items are configurable in the
$scriptInfo
array. - Requires Windows and PowerShell 7+ for GUI support.
- All output is accessible and uses EN-AU spelling.
- See project standards for robust root-based module import and error handling.