title: Powershell to generate file paths correctly in windows and unix
body: <p>I want to generate a string for a file path inside a powershell script. I want this to work in both in windows and mac.</p>
  
  <p>At the moment the code is hardcoded to windows like paths ("\" -> windows, "/" -> unix):
  <code>
  $templatep="$CoreRoot\templates\$serviceName"
  </code></p>
  
  <p>I changed this to:
  <code>
  $templatep= Join-Path $CoreRoot "templates" $serviceName
  </code>
  And it works in mac with Powershell 6.0. BUT it doesn't work in my windows server with Powershell 4. I have to do something like this:</p>
  
  <p><code>
  $templatep= Join-Path $CoreRoot -ChildPath "templates" | Join-Path -ChildPath $serviceName
  </code></p>
  
  <p>Any idea why this is just working in my mac? Is this a new feature in powershell 5 or 6?
  I dont't like the having to pipe multiple Join-Paths. Is there a better way to do this?</p>
  
  <p>Thanks!</p>