roy roy - 10 months ago 97
PowerShell Question

Powershell relative path to repo file

I am trying to refer relative path to file which is in the same repo as powershell script.

I have following dir structure.

├── files
│   └──
├── powershell_scripts
└── my_powershell.ps1

I want to refer
. I tried to use
in the powershell script but it didn't work the way I want.

I want
to pickup
with directory structure.

anyone knows how do this ?



Ok, so in v3 or higher this is simple. If you want the path to the "Repo" folder you could simply refer to the parent of the current folder such as:

$Repo = Resolve-Path "$PSScriptRoot\.."

This will get you the folder object of Repo. From there you could get to your script folder.

Or to directly refer to the file you could do:

Resolve-Path "$PSScriptRoot\..\files\"