I'm executing the following command on a machine where G:
drive does not exist:
Join-Path "G:\" "abc.txt"
In Powershell v5, this returns "G:\abc.txt" as expected. I simply want to join sub-paths and not validate it's existence. On the other hand, in Powershell v4, it fails with the following error:
Join-Path : Cannot find drive. A drive with the name 'G' does not exist.
At line:1 char:1
+ Join-Path "G:\" "abc.txt"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (G:String) [Join-Path], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand
For some reasons I am stuck with using Powershell v4 and cannot make a move to Powershell v5 right now. Is there any out-of-the-box solution for simply joining sub-paths in Powershell v4 or do I need to create a custom solution?