Skip to content

Select-Object cannot target properties that literally contain wildcard characters #25982

@mklement0

Description

@mklement0

Prerequisites

Steps to reproduce

Follow-up to #25509, which was inappropriately closed as by design (also related: #17068):

[PSCustomObject]@{ 'Foo[]' = 'bar' } | Select-Object Foo*, ([WildcardPattern]::Escape('Foo[]'))

Expected behavior

Foo[] Foo[]
----- -------
bar   bar

Note: Strictly speaking, targeting the same property twice would result in an error, but the above is meant to illustrate that both approaches to targeting the property literally named Foo[] should succeed.

Actual behavior

Foo[] Foo`[`]
----- -------
bar   

That is, the Foo[] property cannot be targeted by its full name, even with proper escaping; the column header suggests that the escaped name is mistakenly used verbatim to look for a property by that name (and therefore creates a property by this mistaken name).
(Ditto with -ExpandProperty, where the error message indicates the same thing.)

Error details

Environment data

PowerShell 7.6.0-preview.4

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesWG-ReviewedA Working Group has reviewed this and made a recommendation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Reviewed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions