Skip to content

Select-Object -Property argument that is an escaped wildcard expression retains the escape characters in the resulting property name #17068

@mklement0

Description

@mklement0

Prerequisites

Steps to reproduce

The -Property parameter (conveniently) interprets its arguments as wildcard expressions, so that 'foo' | Select-Object Len* select the .Length property, for instance.

While perhaps a rare scenario, user may want to select properties that literally contain a * character (see this Stack Overflow question for an example).

While escaping the * as `* is effective in bypassing the wildcard matching, the ` char. is inappropriately retained as part of the resulting property name.

Note:

  • If there's a performance concern with respect to correcting this behavior, the pitfall should at least be documented.

  • The workaround is to use a calculated property (see linked Stack Overflow post).

'foo' | Select Len*, 'Bar`*'

Expected behavior

Length Bar*
------ -----
     3

Actual behavior

Length Bar`*
------ -----
     3 

That is, the ` was unexpectedly retained as part of the property name.

Error details

No response

Environment data

PowerShell Core 7.3.0-preview.3

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueNeeds-TriageThe issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions