Skip to content

-RelativeBasePath does not work correctly for registry path. #27567

@plum7x

Description

@plum7x

Prerequisites

Steps to reproduce

If you use Resolve-Path to resolve the path under the registry provider, and -Relative to get relative path, everything is normal up to this point. But if you also use -RelativeBasePath to specify a registry path as base path, then an error will occur regardless.

Expected behavior

PS > Set-Location -LiteralPath 'HKCU:\Software\Classes'
PS > Resolve-Path -Path '.3g*' -Relative
.3g2
.3gp
.3gp2
.3gpp
PS > Resolve-Path -Path '.3g*' -Relative -RelativeBasePath .
.3g2
.3gp
.3gp2
.3gpp
PS > Resolve-Path -Path '.3g*' -Relative -RelativeBasePath $PWD.Path
.3g2
.3gp
.3gp2
.3gpp
PS > Resolve-Path -Path '.3g*' -Relative -RelativeBasePath HKCU:\Software\Classes
.3g2
.3gp
.3gp2
.3gpp

Actual behavior

PS > Set-Location -LiteralPath 'HKCU:\Software\Classes'
PS > Resolve-Path -Path '.3g*' -Relative
.3g2
.3gp
.3gp2
.3gpp
PS > Resolve-Path -Path '.3g*' -Relative -RelativeBasePath .
Resolve-Path: Cannot find path 'HKCU:\Software\Classes\HKEY_CURRENT_USER\Software\Classes' because it does not exist.
PS > Resolve-Path -Path '.3g*' -Relative -RelativeBasePath $PWD.Path
Resolve-Path: Cannot find path 'HKCU:\Software\Classes\HKEY_CURRENT_USER\Software\Classes' because it does not exist.
PS > Resolve-Path -Path '.3g*' -Relative -RelativeBasePath HKCU:\Software\Classes
Resolve-Path: Cannot find path 'HKCU:\Software\Classes\HKEY_CURRENT_USER\Software\Classes' because it does not exist.

Error details

Environment data

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

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions