Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Parent Folder path

$
0
0

I need to reference a number of resources with paths relative to the script folder, and I am using 

$ScriptPath = Split-Path $script:MyInvocation.MyCommand.Path to establish the script path. I had tried just using relative patching, but I had some failures since the path "origin" isn't the script folder, but rather the current folder, and some environments where setting that to user folders. Thus $ScriptPath. Also, these values are stored in some XML that I read into some variables to make maintenance easier down the road, and I then use $ExecutionContext.InvokeCommand.ExpandString($Var) to get an actual path. 

I can use "$ScriptPath\Resources\Resources.xml" to get to a file that is in a subfolder of the current script's folder, but getting to a parent folder I am having trouble with. If I didn't need to use the $ScriptPath variable then "..\Locations.xml" would work, but I do need the variable, and things like "$ScriptPath\..\Locations.xml" don't work.

Anyone point me in the right direction on this? Or should I abandon the approach?

Thanks!
Gordon


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>