title: PowerShell: get all child items recursively - without bin/obj folders
body: <p>I want to get a list of all child items of a number of source folders I want to export (=copy) afterwards. However, I do not want to get the bin/obj folders and their sub contents.</p>
  
  <p>My approach so far:</p>
  
  <pre><code>Get-ChildItem $RootDirectory -Attributes Directory -Include $includeFilder |
    Get-ChildItem -Recurse -exclude 'bin' |% { Write-Host $_.FullName }
  </code></pre>
  
  <p>However, it does not work. The problem seems to be that <code>-exclude 'bin'</code> does not match as the whole folder name down the road (something like <code>C:\Blubb\bin</code>) is matched.</p>
  
  <p>How to match only the folder name and not the whole path in the <code>-exclude</code> statement? Is there maybe an even better approach?</p>