Skip to content

The switch parameters for Split-Path should be mandatory #12991

@sdwheeler

Description

@sdwheeler

This is related to the recent change made in PR #12960

I was reviewing this PR to understand the change needed in the documentation. I also looked at the source code and find that the pattern used by the parameters is confusing. The switch parameters are all optional but are used to define the unique ParameterSet. So, they are mandatory for that parameter set.

PS C:\temp\test> syntax Split-Path | ft -w

Cmdlet     ParameterSetName Parameters
------     ---------------- ----------
Split-Path ParentSet        [-Path] <string[]> [-Parent] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path LeafSet          [-Path] <string[]> [-Leaf] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path LeafBaseSet      [-Path] <string[]> [-LeafBase] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path ExtensionSet     [-Path] <string[]> [-Extension] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path QualifierSet     [-Path] <string[]> [-Qualifier] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path NoQualifierSet   [-Path] <string[]> [-NoQualifier] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path IsAbsoluteSet    [-Path] <string[]> [-Resolve] [-IsAbsolute] [-Credential <pscredential>] [<CommonParameters>]
Split-Path LiteralPathSet   -LiteralPath <string[]> [-Resolve] [-Credential <pscredential>] [<CommonParameters>]

I think the parameters should be changed to Mandatory = true. Are there any risks created by that change?

As a secondary question, what is the use-case scenario for allowing ValueFromPipelineByPropertyName on those switch parameters? Seems like a strange use case and hard to document.

Metadata

Metadata

Assignees

No one assigned

    Labels

    First-Time-IssueEasy issues first time contributors can work on to learn about this projectIssue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions