Title: When New-Item -Path is combined with -Name, the -Path argument is inappropriately treated as a wildcard expression · Issue #17106 · PowerShell/PowerShell · GitHub
Open Graph Title: When New-Item -Path is combined with -Name, the -Path argument is inappropriately treated as a wildcard expression · Issue #17106 · PowerShell/PowerShell
X Title: When New-Item -Path is combined with -Name, the -Path argument is inappropriately treated as a wildcard expression · Issue #17106 · PowerShell/PowerShell
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 reprodu...
Open Graph 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 PowerSh...
X 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 PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/17106
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"When New-Item -Path is combined with -Name, the -Path argument is inappropriately treated as a wildcard expression","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nNote: \r\n * Conceptually related: #14534\r\n\r\nThe following two statements _should_ be equivalent, but aren't:\r\n\r\n```powershell\r\n# OK - with only a -Path argument, the path is taken *literally*\r\n# Creates a subdir. literally named '[test]' with a file 'test.txt' in it.\r\nNew-Item -Force -Path '[test]\\test.txt'\r\n\r\n# !! BROKEN - with -Name also present, the -Path argument is\r\n# !! interpreted as a *wildcard expression*\r\nNew-Item -Force -Path '[test]' -Name 'test.txt'\r\n```\r\n\r\nWith `-Name` also present, `-Path` is unexpectedly treated _as a wildcard expression_.\r\n\r\n### Expected behavior\r\n\r\nBoth commands should (re)create a subdirectory `[test]` with a file `test.txt` in it, and report a `FileInfo` instance for the latter; e.g.:\r\n\r\n```console\r\n\r\n Directory: /Users/jdoe/[test]\r\n\r\nUnixMode User Group LastWriteTime Size Name\r\n-------- ---- ----- ------------- ---- ----\r\n-rw-r--r-- jdoe staff 4/4/2022 17:08 0 test.txt\r\n\r\n```\r\n\r\n\r\n### Actual behavior\r\n\r\nThe 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` ...\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```powershell\r\nPowerShell Core 7.3.0-preview.3\r\n```\r\n\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2022-04-04T21:08:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/17106/PowerShell/issues/17106"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7cab4baf-1c16-5fcc-c231-d819189dc6e6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F5A:E9EB2:107A556:15DD401:6A582EFE |
| html-safe-nonce | a933c808cc676fd0c04317134ff125ae83f3b23439f6dcf79a9a62d0b5142370 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjVBOkU5RUIyOjEwN0E1NTY6MTVERDQwMTo2QTU4MkVGRSIsInZpc2l0b3JfaWQiOiI1OTQ1NDU0MjE4MTAyNDUxOTY2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 32967d216472c14970b0a224af8ce43a603a6d925436228e4cc1dfff7286ada4 |
| hovercard-subject-tag | issue:1192316164 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/17106/issue_layout |
| twitter:image | https://opengraph.githubassets.com/620bc393ffbd4309bbab5b302137a13ad6f95fc8d3b866965095f2bc4c827cc7/PowerShell/PowerShell/issues/17106 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/620bc393ffbd4309bbab5b302137a13ad6f95fc8d3b866965095f2bc4c827cc7/PowerShell/PowerShell/issues/17106 |
| og:image:alt | 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 PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width