Skip to content

GCI of extended-length path "\\?\" returns incorrect items #14668

Closed

Description

@mccarrm

Steps to reproduce

Get-ChildItem -LiteralPath '\\?\D:\'
Get-ChildItem -LiteralPath '\\?\UNC\server\share'

Expected behavior

Gets the items in the specified location.

Actual behavior

Gets the items in the root of the current drive (e.g. C:\).  Same cmdlet in PSVersion 5.1 gets the items in the specified location.

Environment data

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

Activity

  1. added
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    on Jan 26, 2021
  2. mklement0 commented on Jan 26, 2021

    @mklement0
    Contributor

    Related: #10805

    The short of it:

    • In PowerShell Core, long paths are supported by default, so the \\? opt-in prefixes are never needed.

    • However, they should still be supported, not least for the sake of cross-edition code - and currently, they're mostly not.

  3. added
    Issue-BugIssue has been identified as a bug in the product
    WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
    on Jan 27, 2021
  4. daxian-dbw commented on Jan 27, 2021

    @daxian-dbw
    Member

    Definitely a bug that needs to be fixed in my opinion. #14078 doesn't seem to include the specific problem this issue is about -- Get-ChildItem -LiteralPath '\\?\D:\' shows files/folders under C:\ instead, so I think we should not close this issue as a dup.

    Steve Lee (@SteveL-MSFT) mentioned in #10805 (comment)

    I get that users may want to use the \?\ legacy syntax, but it's not clear to me how impactful that is to motivate spending the time to fix this.

    I'm not sure if that statement also applies to this issue. Happy to see other people's thoughts.

  5. AlphaR3C0N commented on Jun 9, 2021

    @AlphaR3C0N

    Another use case for this old syntax is working with volumes in Windows that don't have drive letters (I know it's easy enough to assign letters but in some cases, you don't want to).

    In the attached screenshot, both outputs should be the same (PS7.1.3 left, WPS5.1 right), instead PS7 returns the contents of C: for each volume (There are only 2 sets of results on the right cause the third volume was empty).

    The path returned by $volume.UniqueId is the same in both versions (In format: \\?\Volume{0297bb38-1cf2-40db-abd1-8f7cb8539b8a}\) but after being passed through Get-ChildItem, it always ends up being C: in PS7.

    This was run on Windows 10 Enterprise 21H1.

    Screenshot 2021-06-09 170018

  6. MartinGC94 commented on Apr 2, 2023

    @MartinGC94
    Contributor

    This seems to be working now so I guess this issue can be closed.

  7. daxian-dbw commented on Apr 3, 2023

    @daxian-dbw
    Member

    I have verified this now works in PowerShell 7.4.0-preview.2, so closing the issue.

    image

  8. ghost closed this as completedon Apr 5, 2023
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

    Area-FileSystem-Providerspecific to the FileSystem providerIssue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issuesWG-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