2

What is the benefit of using Join-Path to create a file path instead of just doing something like the following?

$Folder\$FileName
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
SKLAK
  • 3,575
  • 9
  • 32
  • 55

1 Answers1

3

Join-Path benefits:

  • Uses the path-separator defined for the provider on which it's running
  • Supports more than just filesystems (Certificates, registry, etc)
  • Accepts multiple items to join.
  • Accepts credentials
  • Can resolve the result to a full path if it's relative
  • Accepts arguments from the pipeline without a Foreach-Object intermediary
Eris
  • 7,038
  • 1
  • 28
  • 45
  • 2
    One more for you, now that PowerShell is multi-platform, it joins in an appropriate manner for the operating system. – Chris Dent Aug 26 '16 at 06:41