8000 Set-BoxStarterTaskbarOptions - Parameter set cannot be resolved using the specified named parameters. · Issue #458 · chocolatey/boxstarter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Set-BoxStarterTaskbarOptions - Parameter set cannot be resolved using the specified named parameters. #458
Open
@veleek

Description

@veleek

What You Are Seeing?

Set-BoxStarterTaskbarOptions uses Parameter Sets to enforce mutually exclusive parameters e.g.:

        [Parameter(ParameterSetName='AlwaysShowIconsOn')]
        [switch]
        $AlwaysShowIconsOn,

        [Parameter(ParameterSetName='AlwaysShowIconsOff')]
        [switch]
        $AlwaysShowIconsOff,

        [Parameter(ParameterSetName='MultiMonitorOff')]
        [switch]
        $MultiMonitorOff,

        [Parameter(ParameterSetName='MultiMonitorOn')]
        [switch]
        $MultiMonitorOn,

However, Powershell enforces that the provided arguments MUST conform to a SINGLE parameter set, so for the above parameters you can't provide AlwaysShowIconsOn AND MultiMonitorOff in the same command because there's no ParameterSet that supports both values.

To resolve this, MultiMonitorOff (and all other params) would need to include parameter set names allowing it to be included the other parameter sets e.g.

        [Parameter(ParameterSetName='MultiMonitorOff')]
        [Parameter(ParameterSetName='AlwaysShowIconsOn')]
        [Parameter(ParameterSetName='AlwaysShowIconsOff')]
        [switch]
        $MultiMonitorOff,

Unfortunately, this makes it possible to provide conflicting values.

Long story short, it's not easy to enforce multiple mutually exclusive parameter sets in a powershell function. Better to just enforce it in the implementation.

Of note is the fact that the second example doesn't work for me.

What Is Expected?

Any set of valid arguments should be accepted.

How Did You Get This To Happen? (Steps to Reproduce)

Set-BoxstarterTaskbarOptions -Combine Never -AlwaysShowIconsOn -MultiMonitorOn -MultiMonitorMode All -MultiMonitorCombine Never

Output Log

Set-BoxstarterTaskbarOptions : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Set-BoxstarterTaskbarOptions -Combine Never -AlwaysShowIconsOn -Multi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-BoxstarterTaskbarOptions], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,Set-BoxstarterTaskbarOptions

Metadata

Metadata

Assignees

Labels

0 - BacklogIssue is accepted, but is not ready to be worked on or not in current sprintBugIssues where something has happened which was not expected or intended

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0