title: Ignore only files in root directory via Get-ChildItem
body: <p>I have a pretty simple ASP.NET MVC application directory structure, a sample as follows:</p>
  
  <pre><code>root/
  ----- views/
  ---------- index.cshtml
  ---------- web.config
  ----- scripts/
  ---------- main.js
  ---------- plugin.js
  ----- web.config
  </code></pre>
  
  <p>Given this directory structure, I have a small Powershell script that copies everything in the <code>[sourceDir]</code>, ignores a few files, and copies it to <code>[targetDir]</code>. </p>
  
  <p>I'm having an issue with the first step that copies everything in the <code>[sourceDir]</code> using the <code>Get-ChildItem</code> cmdlet. Here is my sample script (edited for brevity): </p>
  
  <pre><code>Get-ChildItem [sourceDir] -Recurse -Exclude web.config | Copy-Item -Destination [targetDir]
  </code></pre>
  
  <p>The problem is that the <code>-Exclude</code> parameter excludes the web.config in the root AND the web.config in the views directory. Technically, it ignores every web.config; however, I just want to ignore the file in the root.</p>
  
  <p>Is it possible to ignore only the web.config in the root via <code>Get-ChildItem</code>? If not, which cmdlet should I use?</p>
  
  <h1>Solution</h1>
  
  <p>As suggested, abandoning the -Exclude parameter for a Where Linq clause was the correct solution. I actually had an array of files to ignore, so I used the <code>-NotIn</code> operator instead of the <code>-NotMatch</code>, sample script:</p>
  
  <pre><code>Get-ChildItem [sourceDir] -Recurse | 
       Where { $_.FullName -NotIn $_filesToIgnore } |
       Copy-Item -Destination [targetDir]
  </code></pre>