Skip to content

Instantly share code, notes, and snippets.

@PshMike
Created March 22, 2020 07:45
Show Gist options
  • Save PshMike/abd64ddcf9a1066aa71b821843541832 to your computer and use it in GitHub Desktop.
Save PshMike/abd64ddcf9a1066aa71b821843541832 to your computer and use it in GitHub Desktop.
BuildPath
Function BuildPath
{
param(
[system.collections.arraylist]$PathElements
)
do
{
$PathElements[1] = join-path $PathElements[0] $PathElements[1]
$PathElements.RemoveRange(0,1)
}
while ($PathElements.count -ge 2)
$PathElements[0]
}
$pieces = @('c:','dir1','\dir2','filename.txt')
BuildPath -PathElements $pieces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment