title: Unable to exclude directory using Get-ChildItem -Exclude parameter in Powershell
body: <p>I am using Powershell v 2.0. and copying files and directories from one location to another. I am using a string[] to filter out file types and also need to filter out a directory from being copied over. The files are being filtered out correctly, however, the directory I am trying to filter <code>obj</code> keeps being copied.</p>
  
  <pre><code>$exclude = @('*.cs', '*.csproj', '*.pdb', 'obj')
      $items = Get-ChildItem $parentPath -Recurse -Exclude $exclude
      foreach($item in $items)
      {
          $target = Join-Path $destinationPath $item.FullName.Substring($parentPath.length)
          if( -not( $item.PSIsContainer -and (Test-Path($target))))
          {
              Copy-Item -Path $item.FullName -Destination $target
          }
      }
  </code></pre>
  
  <p>I've tried various ways to filter it, <code>\obj</code>  or <code>*obj*</code>  or <code>\obj\</code>  but nothing seems to work.</p>
  
  <p>Thanks for any assistance.</p>