Skip to content

Powershell v7.2.0-preview.4 file Hard Link .Target get nothing #15139

@lededev

Description

@lededev

Steps to reproduce

First we use windows 10 original PowerShell make file and it's hard link.

PS Z:\pd> echo "test" > h1.txt
PS Z:\pd> cmd.exe /C mklink /H hardlink_h1.txt .\h1.txt
为 hardlink_h1.txt <<===>> .\h1.txt 创建了硬链接
PS Z:\pd> ls


    目录: Z:\pd


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----          2021/4/2      4:39             14 h1.txt
-a----          2021/4/2      4:39             14 hardlink_h1.txt


PS Z:\pd> (Get-Item .\hardlink_h1.txt).Target
Z:\pd\h1.txt
PS Z:\pd>

It's work fine.
And we use Powershell v7.2.0-preview.4 reproduce this bug

PS Z:\pd> ls

    Directory: Z:\pd

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---            2021/4/2     4:39             14 h1.txt
-a---            2021/4/2     4:39             14 hardlink_h1.txt

PS Z:\pd> (Get-Item .\hardlink_h1.txt).Target
PS Z:\pd>

You can see .Target get nothing.

Expected behavior

PS Z:\pd> (Get-Item .\hardlink_h1.txt).Target
Z:\pd\h1.txt
PS Z:\pd>

Actual behavior

PS Z:\pd> (Get-Item .\hardlink_h1.txt).Target
PS Z:\pd>

Environment data

PS Z:\pd> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.4
PSEdition                      Core
GitCommitId                    7.2.0-preview.4
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS Z:\pd>

image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions