title: How to convert absolute path to relative path in PowerShell?
body: <p>I'd like to convert a path to a relative path in a PowerShell script.
  How do I do this using PowerShell?</p>
  
  <p>For example:</p>
  
  <pre><code>Path to convert: c:\documents\mynicefiles\afile.txt
  Reference path:  c:\documents
  Result:          mynicefiles\afile.txt
  </code></pre>
  
  <p>And</p>
  
  <pre><code>Path to convert: c:\documents\myproject1\afile.txt
  Reference path:  c:\documents\myproject2
  Result:          ..\myproject1\afile.txt
  </code></pre>