title: Two level directory listing with Powershell
body: <p>I've been trying to get a very specific directory listing with no success so far.</p>
  
  <p>Lets say I have a folder structure like this:</p>
  
  <ul>
  <li>C:\inetpub\updates\updatefolder1</li>
  <li>C:\inetpub\updates\updatefolder1\Web\</li>
  <li>C:\inetpub\updates\updatefolder1\Web\ (site code, the structure goes on)</li>
  <li>C:\inetpub\updates\updatefolder1\Scripts\ (db scripts)</li>
  <li>C:\inetpub\updates\updatefolder2</li>
  <li>C:\inetpub\updates\updatefolder2\Web\ (site code, the structure goes on)</li>
  </ul>
  
  <p>Now, when I use foreach, it will look like this:</p>
  
  <pre><code>$folders = Get-ChildItem $UpdateDir -Directory -Recurse -Depth 1 | Select-Object FullName
  
  ForEach($folder in $folders) {
     $folder = folder.TrimStart("@{FullName=").TrimEnd("}") #To get a clean name
  }
  </code></pre>
  
  <p>The result will be as follows:</p>
  
  <pre><code>C:\inetpub\updates\updatefolder1
  C:\inetpub\updates\updatefolder2
  C:\inetpub\updates\updatefolder1\Web\
  C:\inetpub\updates\updatefolder1\Web\ (site code, the structure goes on)
  C:\inetpub\updates\updatefolder1\Scripts\ (db scripts)
  C:\inetpub\updates\updatefolder2\Web\ (site code, the structure goes on)
  </code></pre>
  
  <p>Which is not ok.
  It should look like this:</p>
  
  <pre><code>C:\inetpub\updates\updatefolder1
  C:\inetpub\updates\updatefolder1\Web\
  C:\inetpub\updates\updatefolder1\Web\ (site code, the structure goes on)
  C:\inetpub\updates\updatefolder1\Scripts\ (db scripts)
  C:\inetpub\updates\updatefolder2
  C:\inetpub\updates\updatefolder2\Web\ (site code, the structure goes on)
  </code></pre>
  
  <p>Any fresh ideas ? I've tried several things, other than that foreach loop, still no luck.</p>
  
  <p>Thanks in advance.</p>