Search

Join-Path and Split-Path should not fail if the path does not exist on the current machine by Kirk Munro

Active

4
0
Sign in
to vote
Type: Suggestion
ID: 779068
Opened: 2/12/2013 11:39:01 AM
Access Restriction: Public
0
Workaround(s)
Join-Path and Split-Path both fail if they are joining or splitting file paths that use a drive letter that is not on the local machine. Since PowerShell has Remoting as a core feature, it is not uncommon to do some work in a remote session and some work locally. As a result, you may be processing paths that contain drive letters that exist on a remote machine but not on the local system. If you need to use Join-Path or Split-Path on such a path, you will receive an error message that the drive does not exist. This is very limiting for these otherwise highly useful cmdlets.

A scenario where you might want to do something with this: querying a remote machine to get the path for a file, processing it locally to get the containing folder, and then invoking Move-Item to move the file from remote machine 1 to remote machine 2. If you don't have the same drive on the local system, the processing to get the containing folder work fails.
Details (expand)
How often does this happen?
Always Happens
Have you seen this problem before in this product?
Yes, this happens in all previous versions
Reproduction Steps
On a system where you don't have a d drive, invoke the following:

Split-Path -Path D:\A\b\c.txt -Parent
Expected Results
This should return:

D:\A\b
File Attachments
0 attachments
Sign in to post a comment.
Posted by Roman Kuzmin on 2/21/2013 at 9:55 AM
For me: split-path works in v3, join-path fails.
Posted by Stephen Mills on 2/20/2013 at 10:50 PM
I tried this in V3 and it worked for me. It didn't matter if I had the drive letter or not. Did you try it in V2 instead? This bug does exist there.
Sign in to post a workaround.