PowerShell parameter sets allow cmdlet parameters to be grouped so that only certain parameters can be used in combination (see PowerShell: Cmdlet Parameter Sets). When parameter sets are used, there needs to be a mechanism for specifying what parameter set is associated when there is no parameter specified when invoking a Cmdlet. The DefaultParameterSetName property of the CmdletBinding attribute (see About Functions CmdletBindingAttribute) identifies which parameter set is the default parameter set and hence the parameter set invoked when no parameter is specified to a cmdlet.
To demonstrate the issue consider a cmdlet, CreateArtifacts.ps1, which is used during build to create artifacts. The parameters and parameter sets for this cmdlet are defined as follows:
param
(
[Parameter(ParameterSetName='Debug')]
[switch] $IsDebug,
[Parameter(ParameterSetName='Release')]
[switch] $IsRelease
)
param
(
[Parameter(ParameterSetName='Debug')]
[switch] $IsDebug,
[Parameter(ParameterSetName='Release')]
[switch] $IsRelease
)
No comments :
Post a Comment