external help file | Module Name | online version | schema |
---|---|---|---|
PowerShellLib-help.xml |
PowerShell-Lib |
2.0.0 |
Reads valid input.
Read-ValidInput [-Prompt] <String> [-ValidityCheck] <ScriptBlock[]> [-ErrorMessage] <String[]>
[<CommonParameters>]
The "Read-ValidInput" cmdlet checks the input against a script and displays a error message if the check fails. It loops until a valid answer can be returned.
$InputPath = Read-ValidInput `
-Prompt "The input path" ` -ValidityCheck @( {Test-Path $Answer} ) ` -ErrorMessage @( "Invalid path!" )
A description of the input that the user is asked for.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
A script to validate the user's input.
Type: ScriptBlock[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The error message that is shown when the validation fails.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
https://github.com/Dargmuesli/PowerShell-Lib/blob/master/PowerShell-Lib/Docs/Read-ValidInput.md