Skip to content
This repository was archived by the owner on Feb 24, 2021. It is now read-only.
This repository was archived by the owner on Feb 24, 2021. It is now read-only.

Example validation: Fails if a parameter has a ValidateSet #242

Open

Description

The following code does not take in account if there are a validate set on a mandatory parameter.
Also, this code should be split out to a separate function.

<#
Check for mandatory parameters.
Assume the parameters are all in the 'all' parameter set.
#>
$isParameterMandatory = $exampleCommand.Parameters[$parameterName].ParameterSets['__AllParameterSets'].IsMandatory
if ($isParameterMandatory)
{
<#
Convert '1' to the type that the parameter expects.
Using '1' since it can be converted to String, Numeric
and Boolean.
#>
$exampleParameters.Add($parameterName, ('1' -as $parameterType))
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThe issue is an enhancement request.help wantedThe issue is up for grabs for anyone in the community.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions