New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating symbolic links or junctions with New-Item doesn't work if target contains '[' or ']' #6232
Comments
It is expected behavior because we support wildcards in paths. Perhaps we could add |
|
|
To be clear: wildcard support should not apply when creating new items.
Similarly, the @kwkam: |
Okay I forgot I was using a patched(#5896) build. @mklement0 For consistency with other cmdlet's |
I wasn't suggesting that The reason for suggesting that is that Conceptually speaking, Unfortunately, it currently does accept a path, namely a relative one: either relative to the path specified in Aside from that, For consistency, given that |
Hey! Googling an Error lead me here. Trying to create a Symlink to a path that contains square brackets using New-Item -Path C:\my\path\cover.jpg -ItemType SymbolicLink -Value C:\my\path[1995]\cover.jpg "not found" Has this bug been fixed yet? |
I see a lot of PRs with @kwkam's work but I'm not sure that specific issue has been completely fixed yet. |
This is definitely still happening in 6.2.0. |
Running 6.2.2 on Linux and found this issue after hours of scratching my head. In my use case in particular it's important the original file names are preserved. I tried escaping wildcard characters in the value I pass to What's confusing me the most is from what I read I still don't quite understand why |
This comment was marked as outdated.
This comment was marked as outdated.
I think this could be fixed with #13134 /cc @mklement0 |
Meanwhile you can use
|
Thanks, @OctaneTwisted, but this doesn't actually work:
|
You're right, sorry. You actually need to escape it twice: Or get tab completion to help you out when typing out the target path, since it gives you an escaped path ( 'asdf `[hello`]\test.txt' ), and just put that though Escape() once. |
Thanks, @OctaneTwisted - good to know (and certainly unexpected; related: #7999). Also worth noting that the workaround will break once the already green-lit proposal to treat a |
Have same problem. Three years past and still not solved... Quite annoying for me, since I use BitTorrents to download files (whose names usually include '[', ']' and '&'), and use symbolic links to sync them between my disk and OneDrive. I'm not familiar with PowerShell, but after reading this topic, as far as I'm concerned, I agree with @mklement0 that
...And it seems much easier to use old By the way, for further reference, my current edition is PowerShell 7.2.1.
|
Hello!! So I just hit this issue And my kind Discord friend santisq asked me to test it with the double escapement. That did the trick!
|
A quick script, to test a few of the suggestions mentioned here or in other pages.
My results (all fail)
|
What worked for me is replacing
|
@sam-6174, yes, that's a viable workaround (previously mentioned); note that none of the double quotes are needed in your sample call. Also, since your example creates a hard link (
|
Still relevant. |
As it turns out, there's actually not enough quotes in the original code, i.e. this...
... needs to be updated to this...
Without these quotes, the original code will fail if |
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
The text was updated successfully, but these errors were encountered: