How to convert relative path to absolute path in PowerShell?
$path1 = C:/1/2/3/
$parth2 = ../../base/
=====
$result = C:/1/base/
(Join-Path $path1 $path2) | Resolve-Path
If your path is not existent yet, most of the above will blow up on you.
Either of the following will work even if the path doesn't exist yet:
[IO.Path]::GetFullPath(".\abc")
$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\abc.txt")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With