Title: Creating symbolic links or junctions with New-Item doesn't work if target contains '[' or ']' · Issue #6232 · PowerShell/PowerShell · GitHub
Open Graph Title: Creating symbolic links or junctions with New-Item doesn't work if target contains '[' or ']' · Issue #6232 · PowerShell/PowerShell
X Title: Creating symbolic links or junctions with New-Item doesn't work if target contains '[' or ']' · Issue #6232 · PowerShell/PowerShell
Description: Steps to reproduce Type on an NTFS/ReFS file system: New-Item -Path '[target]' -ItemType Directory Try creating a junction (or symbolic link, substitute with 'SymbolicLink' in the -ItemType parameter) New-Item -Path '[source]' -Value '[t...
Open Graph Description: Steps to reproduce Type on an NTFS/ReFS file system: New-Item -Path '[target]' -ItemType Directory Try creating a junction (or symbolic link, substitute with 'SymbolicLink' in the -ItemType paramet...
X Description: Steps to reproduce Type on an NTFS/ReFS file system: New-Item -Path '[target]' -ItemType Directory Try creating a junction (or symbolic link, substitute with 'SymbolicLink' in the -...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/6232
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Creating symbolic links or junctions with New-Item doesn't work if target contains '[' or ']'","articleBody":"Steps to reproduce\r\n------------------\r\n\r\n1. Type on an NTFS/ReFS file system:\r\n```\r\nNew-Item -Path '[target]' -ItemType Directory\r\n```\r\n2. Try creating a junction (or symbolic link, substitute with 'SymbolicLink' in the -ItemType parameter)\r\n```\r\nNew-Item -Path '[source]' -Value '[target]' -ItemType Junction\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\nThe junction should be created even if the target path contains square bracket characters\r\n\r\nActual behavior\r\n---------------\r\n An error message is resulted:\r\n```\r\nnew-item : Cannot find path '[target]' because it does not exist.\r\nAt line:1 char:1\r\n+ New-Item -Path '[source]' -Value '[target]' -Itemtype Junction\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n+ CategoryInfo : InvalidOperation: (:) [New-Item], PSInvalidOperationException\r\n+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.NewItem Command\r\n```\r\nNote: the command **can** be made to work with double escapes, but it seems hacky.\r\n```\r\nnew-item -path '[source]' -value \"```[target```]\" -Itemtype Junction\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- provide the output of $PSVersionTable --\u003e\r\n\r\n```\r\nName Value\r\n---- -----\r\nPSVersion 6.0.1\r\nPSEdition Core\r\nGitCommitId v6.0.1\r\nOS Microsoft Windows 6.1.7601 S\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n","author":{"url":"https://github.com/lkydev","@type":"Person","name":"lkydev"},"datePublished":"2018-02-24T04:29:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":27},"url":"https://github.com/6232/PowerShell/issues/6232"}
| 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:7bad3c31-2f4b-a84d-2f34-2041f8afd938 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E740:21E1C8:23FCD56:301D9C0:6A59A470 |
| html-safe-nonce | 9ce0d962b669ec30191929c0cc8016cbfdfadbfb502798d621830c14bd21d2d8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzQwOjIxRTFDODoyM0ZDRDU2OjMwMUQ5QzA6NkE1OUE0NzAiLCJ2aXNpdG9yX2lkIjoiODM2NDQ5MDQyODk3NzM1NzkzNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 783238dc502b6e7676ca06ab69d8fb3a1e20ed32347bb6d51d2bdb013ab8105c |
| hovercard-subject-tag | issue:299910678 |
| 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/6232/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cf375cba96d22d668bb6528a09d37cd851bb6eb8e490a5531b9f0972456b59f6/PowerShell/PowerShell/issues/6232 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cf375cba96d22d668bb6528a09d37cd851bb6eb8e490a5531b9f0972456b59f6/PowerShell/PowerShell/issues/6232 |
| og:image:alt | Steps to reproduce Type on an NTFS/ReFS file system: New-Item -Path '[target]' -ItemType Directory Try creating a junction (or symbolic link, substitute with 'SymbolicLink' in the -ItemType paramet... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lkydev |
| hostname | github.com |
| expected-hostname | github.com |
| None | a540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5 |
| 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 | 0b971869dd75eec26500a9de7e85b8137c6bf0f6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width