Prerequisites
Steps to reproduce
Note:
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.3
Visuals
No response
Prerequisites
Steps to reproduce
Note:
The following two statements should be equivalent, but aren't:
With
-Namealso present,-Pathis unexpectedly treated as a wildcard expression.Expected behavior
Both commands should (re)create a subdirectory
[test]with a filetest.txtin it, and report aFileInfoinstance for the latter; e.g.:Actual behavior
The second command is situationally either a quiet no-op, or fails when wildcard pattern
[test]matches an existing file namedtoreor ... or inappropriately targets an existing directory namedtore...Error details
No response
Environment data
Visuals
No response