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 '[target]' -ItemType Junction
Expected behavior
The junction should be created even if the target path contains square bracket characters
Actual behavior
An error message is resulted:
new-item : Cannot find path '[target]' because it does not exist.
At line:1 char:1
+ New-Item -Path '[source]' -Value '[target]' -Itemtype Junction
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Item], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.NewItem Command
Note: the command can be made to work with double escapes, but it seems hacky.
new-item -path '[source]' -value "```[target```]" -Itemtype Junction
Environment data
Name Value
---- -----
PSVersion 6.0.1
PSEdition Core
GitCommitId v6.0.1
OS Microsoft Windows 6.1.7601 S
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Steps to reproduce
Expected behavior
The junction should be created even if the target path contains square bracket characters
Actual behavior
An error message is resulted:
Note: the command can be made to work with double escapes, but it seems hacky.
Environment data