title: How to simply extract leading N parts of a path?
body: <p>I've got a bunch of directory names and file names, some are absolute path, some are relative path. I just wish to get the 2 leading parts of each path. Input:</p>
  
  <pre><code>D:\a\b\c\d.txt\
  c:\a
  \my\desk\n.txt
  you\their\mine
  </code></pre>
  
  <p>I expect to get:</p>
  
  <pre><code>D:\a
  c:\a
  \my\desk
  you\their
  </code></pre>
  
  <p>Is there a convenient way in PowerShell to achieve this?</p>