Skip to content

New-Item cannot create symlink/hardlink for file with name containing bracket #25744

Closed as duplicate

Description

@wumo

Prerequisites

Steps to reproduce

As for latest 7.5.2, the following error happened:

> Test-Path -LiteralPath "a\a[b].txt"
# return True
> New-Item -ItemType SymbolicLink -Path "a[b].txt" -Target "a\a[b].txt"
# New-Item: Cannot find path 'a\a[b].txt' because it does not exist.

Expected behavior

PS> New-Item -ItemType SymbolicLink -Path "a[b].txt" -Target "a\a[b].txt"

 Directory: E:\test

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
la---           7/10/2025    02:24              0 a[b].txt -> a\a[b].txt

Actual behavior

PS> New-Item -ItemType SymbolicLink -Path "a[b].txt" -Target "a\a[b].txt"

New-Item: Cannot find path 'a\a[b].txt' because it does not exist.

Error details

Environment data

PS > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.5.2
PSEdition                      Core
GitCommitId                    7.5.2
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Activity

  1. added
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    on Jul 9, 2025
  2. similar-issues-ai commented on Jul 9, 2025

    @similar-issues-ai

    We've found some similar issues:

    If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

    Note: You can give me feedback by 👍 or 👎 this comment.

  3. mklement0 commented on Jul 9, 2025

    @mklement0
    Contributor

    The best duplicate is:

    The following PR fixed the problem:

    However, it seems that the PR fixed hasn't landed yet: it wasn't slated for back-porting to v7.5.x, and the current v7.6.x preview (v7.6.0-preview.4) release predates the PR.

    In other words: the fix should land in the next preview version, presumably named v7.6.0-preview.5

  4. microsoft-github-policy-service commented on Jul 15, 2025

    @microsoft-github-policy-service
    Contributor

    📣 Hey @wumo (@wumo), how did we do? We would love to hear your feedback with the link below! 🗣️

    🔗 https://aka.ms/PSRepoFeedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions