-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Note:
- Conceptually related: New-Item -Target parameter mishandles paths that look like wildcard patterns when creating symbolic links / reparse points #14534
The following two statements should be equivalent, but aren't:
# OK - with only a -Path argument, the path is taken *literally*
# Creates a subdir. literally named '[test]' with a file 'test.txt' in it.
New-Item -Force -Path '[test]\test.txt'
# !! BROKEN - with -Name also present, the -Path argument is
# !! interpreted as a *wildcard expression*
New-Item -Force -Path '[test]' -Name 'test.txt'With -Name also present, -Path is unexpectedly treated as a wildcard expression.
Expected behavior
Both commands should (re)create a subdirectory [test] with a file test.txt in it, and report a FileInfo instance for the latter; e.g.:
Directory: /Users/jdoe/[test]
UnixMode User Group LastWriteTime Size Name
-------- ---- ----- ------------- ---- ----
-rw-r--r-- jdoe staff 4/4/2022 17:08 0 test.txt
Actual behavior
The second command is situationally either a quiet no-op, or fails when wildcard pattern [test] matches an existing file named t or e or ... or inappropriately targets an existing directory named t or e ...
Error details
No response
Environment data
PowerShell Core 7.3.0-preview.3Visuals
No response
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module