Skip to content

Get-Item -LiteralPath with FileSystem should fail on paths with wildcards #5057

@nightroman

Description

@nightroman

If a path specified by -LiteralPath does not exist (or is not valid, i.e.
contains forbidden characters) then Get-Item should emit an error.
Currently this does not happen if a path is defined as a wildcard.

The change #4866 fixed this issue for Remove-Item.
The same or similar should be done for Get-Item.

Example:

Given items z.* and [z] do not exist
EDIT: Given item [z] does not exist. As for z.*, it is always "invalid" for LiteralPath.

Get-Item -LiteralPath z.*
Get-Item -LiteralPath [z]

Expected result:

Get-Item emit errors about not found items.

In fact, an error for z.* may even be different, namely "Illegal characters
in the path" because * or ? are illegal for -LiteralPath and FileSystem.

Actual result:

The above commands silently return nothing.

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions