< Back
Register-PSFConfigValidation
Post
NAME Register-PSFConfigValidation
SYNOPSIS
Registers a validation scriptblock for use with the configuration system.
SYNTAX
Register-PSFConfigValidation [-Name] <String> [-ScriptBlock] <ScriptBlock> [<CommonParameters>]
DESCRIPTION
Registers a validation scriptblock for use with the configuration system.
The scriptblock must be designed according to a few guidelines:
- It must not throw exceptions
- It must accept a single parameter (the value to be tested)
- It must return an object with two properties: 'Message', 'Value' and 'Success'.
The Success property should be boolean and indicate whether the value is valid.
The Value property contains the validated input. The scriptblock may legally convert the input (For example from
string to int in case of integer validation)
The message contains a string that will be passed along to an exception in case the input is NOT valid.
PARAMETERS
-Name <String>
The name under which to register the validation scriptblock
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ScriptBlock <ScriptBlock>
The scriptblock to register
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Register-PSFConfigValidation -Name IntPositive -ScriptBlock $scriptblock
Registers the scriptblock stored in $scriptblock as validation with the name IntPositive
RELATED LINKS
SYNOPSIS
Registers a validation scriptblock for use with the configuration system.
SYNTAX
Register-PSFConfigValidation [-Name] <String> [-ScriptBlock] <ScriptBlock> [<CommonParameters>]
DESCRIPTION
Registers a validation scriptblock for use with the configuration system.
The scriptblock must be designed according to a few guidelines:
- It must not throw exceptions
- It must accept a single parameter (the value to be tested)
- It must return an object with two properties: 'Message', 'Value' and 'Success'.
The Success property should be boolean and indicate whether the value is valid.
The Value property contains the validated input. The scriptblock may legally convert the input (For example from
string to int in case of integer validation)
The message contains a string that will be passed along to an exception in case the input is NOT valid.
PARAMETERS
-Name <String>
The name under which to register the validation scriptblock
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ScriptBlock <ScriptBlock>
The scriptblock to register
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Register-PSFConfigValidation -Name IntPositive -ScriptBlock $scriptblock
Registers the scriptblock stored in $scriptblock as validation with the name IntPositive
RELATED LINKS