title: How does the Get-ChildItem -Exclude Parameter work?
body: <p>How does the Get-ChildItem -Exclude parameter work?  What rules does it follow?</p>
  
  <p>The Get-Help for Get-ChildItem isn't detailed at all:</p>
  
  <blockquote>
    <p>Omits the specified items. The value of this parameter qualifies the
    Path parameter. Enter a path element or pattern, such as "*.txt".
    Wildcards are permitted.</p>
  </blockquote>
  
  <p>And on Stackoverflow and elsewhere the general consensus seems to be it's too difficult to use and we should all just pipe the output of Get-ChildItem to Where-Object instead.</p>
  
  <p>While I'm willing to use Where-Object I'm curious as to the rules -Exclude follows.</p>
  
  <p>For example, I have a folder with the following sub-folders:</p>
  
  <pre><code>HsacFixtures
  HsacFixturesBuild
  RestFixture
  RestFixtureBuild
  </code></pre>
  
  <p>If I execute the following command:</p>
  
  <pre><code>Get-ChildItem $rootFolderPath -Exclude HsacFixturesBuild -Directory
  </code></pre>
  
  <p>it returns the results expected:</p>
  
  <pre><code>HsacFixtures
  RestFixture
  RestFixtureBuild
  </code></pre>
  
  <p>However, if I add a -Recurse parameter: </p>
  
  <pre><code>Get-ChildItem $rootFolderPath -Exclude HsacFixturesBuild -Directory -Recurse
  </code></pre>
  
  <p>Then it returns sub-folders in the HsacFixturesBuild folder.</p>
  
  <p>I've also tried <code>HsacFixturesBuild\</code> and <code>HsacFixturesBuild\*</code>, which have the same results.</p>
  
  <p>So does -Exclude only apply to immediate children, and not to grand-children or deeper sub-folders?</p>