3

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,738
  • 21
  • 105
  • 131
SKLAK
  • 3,825
  • 9
  • 33
  • 57

1 Answers1

4

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,378
  • 1
  • 30
  • 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