This is a simple wrapper for the great Sharprompt library to make it easier to use in PowerShell.
Note
This module is now compatible with PowerShell 5.1 and above.
This is still a work in progress and not all features are supported yet.
Install the module from the PowerShell Gallery
Install-Module -Name PSSharpromptYou can also install the module from the GitHub repository by downloading the latest release.
Note
You will need to include the Sharprompt.dll in the same directory as the module dll.*
Import-Module .\PSSharprompt.dll- Show-PromptInput
- Show-PromptPassword
- Show-PromptConfirm
- Show-PromptSelect
- Show-PromptMultiSelect
- Set-PromptColorSchema
- Set-PromptSymbol
The following functions support validation:
- Show-PromptInput
- Show-PromptList
- Show-PromptPassword
You can use the following parameters to validate the input:
[switch] -Required
[int] -MinLength
[int] -MaxLength
[string] -RegularExpressionWhen not supplied, they have the same defaults as Sharprompt.
Make sure to import the module first
Import-Module PSSharprompt$Name = Show-PromptInput -Message 'What is your name?' -Default 'John Doe'
"Hello, $Name!"$Password = Show-PromptPassword -Message 'Enter your password'
"Your password is valid!"$Password = Show-PromptPassword -Message 'Enter your password' -Required -MinLength 8 -MaxLength 16 -RegularExpression '^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&\._\-\(\)]+$'
"Your password is valid!"$Confirm = Show-PromptConfirm -Message 'Are you sure?' -Default $false
"They said: $Confirm"$Selected = Show-PromptSelect -Message 'Select your favorite color' -Items 'Red', 'Green', 'Blue'
$Selected$Selected = Show-PromptMultiSelect -Message 'Select your favorite colors' -Items 'Red', 'Green', 'Blue'
$Selected -join ', '