Skip to content
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

Add a -PSProvider parameter to Convert-Path and Resolve-Path, for symmetry with Get-Location #10494

mklement0 opened this issue Sep 6, 2019 · 0 comments


Copy link

commented Sep 6, 2019

Related: #2993

Summary of the new feature/enhancement

Get-Location already supports a -PSProvider parameter that allows you to specify the provider context explicitly rather than relying on the provider that happens to underlie the current location.

Convert-Path / Resolve-Path should support this parameter too, so that full native / full PS paths can be obtained relative to a given provider's current location without having to rely on the current location.

If this parameter were added, the following tests should pass:

# Set the current filesystem location.
Push-Location Temp:\
$null > ($tmpFile = "$PID.txt")

# Switch to a different provider
Push-Location Env:\

# Resolve a path relative to the filesystem provider to an absolute native path. 
Convert-Path -LiteralPath $tmpFile -PSProvider FileSystem | 
  Should -Be (Join-Path (Get-Location -PSProvider FileSystem).ProviderPath $tmpFile)

# Resolve a path relative to the filesystem provider to an absolute PS path.
Resolve-Path -LiteralPath $tmpFile -PSProvider FileSystem | 
  Should -Be (Join-Path (Get-Location -PSProvider FileSystem).Path $tmpFile)

Remove-Item $tmpFile

Proposed technical implementation details (optional)

I presume there's potential for reuse of the existing code in Get-Location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.