7 min read
New ScriptRunner Release Enhances Enterprise IT Automation with Better Security, Transparency and Efficiency
The latest ScriptRunner release enhances Enterprise IT automation with three powerful features: the new Approval Process
ScriptRunner Blog
A very important and end user-friendly feature of ScriptRunner is the graphical interface for entering PowerShell parameters in the Admin and Delegate App. Easy-to-use input is an essential requirement for all customers in day-to-day IT operations. The PowerShell scripts map a variety of business logic for automation and delegation. However, the scripts should not be used on the command line, but via an easy-to understand graphical interface. This article shows you how to use PowerShell parameters in the input forms and how to design them. If you consider these suggestions, your users will thank you!
PowerShell does not offer a satisfactory solution for the problem of graphic representation. As a „home remedy“, you can encode WPF forms or use extensive XAML code. As practice has shown, however, this variant has many disadvantages:
The ScriptRunner Admin and Delegate App is specifically designed for administrators and service desk staff who want to use PowerShell scripts in daily IT operations with a graphical interface.
The following features were at the centre of the design and development:
To map these helpful functions, ScriptRunner operates in a simplified way according to the following principles:
From these basic principles, several conditions and best practices for script development are derived:
PowerShell has built-in support for data types for parameters. The common input of input parameters on the command line is based on the type string. PowerShell can convert the String input type to different other types depending on the declared script parameter. If no type is declared, PowerShell converts to a suitable format depending on the notation.
Best practice: Use the declaration of data types in PowerShell, since type-free conversion is often the cause of processing problems in the script and cmdlets.
The generic display in the ScriptRunner apps supports and checks valid value ranges for the following data types:
ScriptRunner displays the mentioned data types in the generic browser interface of the Admin App and the Delegate App. The type of display in the Admin App also depends on whether an action is to be configured (EDIT mode) or started (RUN mode).
PowerShell Data Type |
Representation in theadmin app |
Representation in theDelegate App |
String Types |
text input field |
text input field |
Number Types |
Text input field with check for number type and value range |
Text input field with check for number type and value range |
array types |
Text input field for multiple values with separators |
Text input field for multiple values with separators |
[switch] |
selection tick |
selection tick |
[DateTime] |
DatePicker Version 2018R3 |
DatePicker Version 2018R3 |
[TimeSpan] |
Not implemented yet |
Not implemented yet |
[PSCredential] |
Dropdown selection of credentials stored in ScriptRunner or a password store |
Hidden |
[SecureString] |
Text input field switchable plain text display, hidden display Version 2018R3 |
Text input field switchable plain text display, hidden display Version 2018R3 |
Display with extended PowerShell parameter declarations
Alongside pure data type declaration, PowerShell allows an extended parameter declaration. This is mainly used for validation functions of the input and its sequence. ScriptRunner supports the declarations listed in the table. This has the following advantages:
The display options in the Admin App also depend on their attributes.
PowerShell Declaration |
Admin App in EDIT Mode |
Admin App in RUN Mode and Delegate App |
Generally also without extended declaration |
The parameter can be preset with a value. The input is checked for a valid value range depending on the data type. The value can be changed by the user or is permanently assigned. |
The input is checked for a valid value range depending on the data type. The input field for predefined parameters is hidden. |
[Parameter (Mandatory=$true)] |
The input field is marked with a gray sign. The parameter can be preset with a value. |
The input field is bordered in red and provided with a red hint sign. The script cannot be started without valid input or selection. |
[Parameter (Position=n)] |
The input field is positioned at the nth position in the display sequence. |
The input field is positioned at the nth position in the display sequence. |
[ValidateRange(min,max)] |
The input field checks entries for compliance with the specified minimum and maximum values. If the input is incorrect, the input field is marked with a red frame and the script cannot be started. |
The input field checks entries for compliance with the specified minimum and maximum values. If the input is incorrect, the input field is marked with a red frame and the script cannot be started. |
[ValidateLenght(min,max)] |
The input field checks inputs for compliance with the specified minimum and maximum value for the character length. If the input is incorrect, the input field is marked with a red frame and the script cannot be started. |
The input field checks inputs for compliance with the specified minimum and maximum value for the character length. If the input is incorrect, the input field is marked with a red frame and the script cannot be started. |
[ValidateSet(‘a’,’b’,’c’)] |
The input field appears as a dropdown menu with the values a, b and c. In combination with array types, a dropdown with multiple selection is displayed. |
The input field appears as a dropdown menu with the values a, b and c. In combination with array types, a dropdown with multiple selection is displayed. If the input is incorrect, the input field is marked with a red frame and the script cannot be started. |
<# .SYNOPSIS An example for the generic display of input parameters with different data types and extended parameter declarations in ScriptRunner Admin and Delegate App .PARAMETER MyString Please enter a simple string .PARAMETER MyStringSelect Please select one of the simple strings .PARAMETER MyUintArray Please enter several numbers, separated by comma .PARAMETER MyStringArray Please select multiple strings, use CTRL Click .PARAMETER MyNumber Please enter a Number .PARAMETER MySwitch Please select the box .PARAMETER MyCredential Please select a Credential #> param ( [Parameter(Mandatory=$true)] #this input is mandatory [ValidateLength(5, 10)] #only min 5 and max 10 chars allowed [string]$MyString, [Parameter(Mandatory=$true,Position=4)] #this param will displayed on fourth position [ValidateSet('first','second','third')] #only these values are allowed [string]$MyStringSelect, [ValidateRange(7, 18)] #the input min/max per value is allowed, comma separated [uint16[] ]$MyUintArray, [ValidateSet('one','two','three','four')] #only this values are allowed, multiple selection possible [string[]]$MyStringArray, [Parameter(Position=2)] [ValidateRange(2018,2023)] #the input of minimum 2018 and maximum 2023 is allowed [int]$MyNumber, [switch]$MySwitch, #defines a switch [PSCredential]$MyCredential #defines a PowerShell credential parameter )
The application of this script header leads to the display of the different properties in the automatically generated form.
In the EDIT mode of the ScriptRunner Admin App, the order and possible default values are checked in the script itself. A check for „mandatory“ is not useful in this mode and therefore not possible.
All values can now be preset manually or by dropdown etc. via configuration. Default values appear directly in the input form in RUN mode, but can still be changed by the user. If the option ‚cannot be changed at script runtime‘ is set at the parameter, the default value is used as a fixed value. The form in RUN mode is shortened by this parameter in the display. This is based on the principle that non-changeable values should no longer be displayed. In this case, the user concentrates completely on the input fields that are still open.
The display and selection of the data type [PSCredential] is only possible in EDIT mode.
The RUN mode of the admin app is used to test the settings and script execution, which is why the input fields in this mode behave analogously to the Delegate App. In this mode, the check for „mandatory“ is made first. These fields are shown with a red frame and an exclamation mark if they are still empty, i.e. no value has been entered. Afterwards, each field is validated during input. Notes on validation are displayed directly in the input field if it is empty.
If invalid values are entered or if the validation algorithm detects an error, the corresponding field is framed in red.
The script can also not be started if there are missing or incorrect entries. The corresponding ok or run button is inactive. This prevents starting scripts with wrong or unauthorized input values, which would lead to an error in execution.
Display and validations in the Delegate App are analogous to RUN mode in the Admin App.
Display of Parameter Sets
Additonal options are provided by parameter sets, which were originally introduced in PowerShell to map a use case differently in a PowerShell cmdlet. In combination with scripts and ScriptRunner, this leads to very interesting additional options.
An example: Users have different properties in the AD. In addition to simple information such as phone number, department etc. there is status information such as „locked“ or „inactive“. If all these possibilities are combined in one script „Change User“, parameter sets can be used to map different use cases.
The script header below shows three use cases:
<# .SYNOPSIS Change a user's properties. .PARAMETER UserName Select the user account to change. .PARAMETER Unlock Unlock the user account. .PARAMETER Enable Enable/Disable the user account (Keep | Enable | Disable). .PARAMETER City Change the city (AD 'l' property) .PARAMETER Department Change the department (AD 'department' property) .PARAMETER StreetAddress Change the office street address (AD 'streetAddress' property) .PARAMETER OPhone Change the office phone number (AD 'telephoneNumber' property) #> [CmdletBinding()] Param ( [Parameter(Mandatory=$true)] [string]$UserName, [Parameter(Mandatory=$false, ParameterSetName="Unlock")] [switch]$Unlock, [Parameter(Mandatory=$false, ParameterSetName="EnableDisable")] [ValidateSet('Keep', 'Enable', 'Disable')] [string]$Enable = 'Keep', [Parameter(Mandatory=$false, ParameterSetName="Change")] [string]$City, [Parameter(Mandatory=$false, ParameterSetName="Change")] [string]$Department, [Parameter(Mandatory=$false, ParameterSetName="Change")] [string]$StreetAddress, [Parameter(Mandatory=$false, ParameterSetName="Change")] [string]$OPhone )
Now you can configure three cases with one and the same script in ScriptRunner. The distinction is made by selecting the parameter set in the respective action. The respective parameter set for the use cases can already be defined in the EDIT mode of the Admin App. If no parameter is specified, the user can select the parameter set in the Delegate App or in the RUN of the Admin App.
Different use cases in actions per parameter set
The displayed input form changes dynamically with the selection of the respective parameter set. If the parameter set has already been specified in the configuration, the appropriate form for the case appears for the user.
As a result, you have defined three actions that implement different use cases. In the application, each use case automatically receives a suitable form with the necessary input fields. Input fields that do not belong to the use case or parameter set are hidden.
A consistent continuation in the use of input parameters results from the use of ScriptRunner Queries. This does not require any changes to the script itself, only appropriate configurations need to be made.
In EDIT mode, the Admin App is assigned a previously configured query to an input parameter. The task of the query is to „get“ a selection list for the respective input parameter at runtime. The list of the determined input values appears in the form as a dropdown. If the input parameter is declared as an array, a drop-down appears with the option of multiple selection.
Assign a query to an input parameter, here as a dependent cascade
In the query configuration, you can also specify whether a search field and a search function should appear. The search field has two tasks:
In combination with corresponding attribute queries, the attributes of values can already be displayed.
Feb 24, 2025 by Heiko Brenn
The latest ScriptRunner release enhances Enterprise IT automation with three powerful features: the new Approval Process
Jan 28, 2025 by Jeffery Hicks
Changelogs keep your software updates clear and organized. Learn the best practices for creating and managing them in...
Dec 19, 2024 by Jeffery Hicks
Boost IT efficiency with Winget and PowerShell! Learn how to automate app installations, updates, and management...
Frank Kresse is Head of Product and CEO of ScriptRunner. As the inventor of the automation and delegation solution for PowerShell, he advises clients on use case scenarios and develops solutions for the automation and the digitalization of their processes. He is also involved in technology start-ups.