title: Why doesn't PowerShell Where-Object work when passing a variable?
body: <p>The function</p>
  
  <pre><code> function findf {
       Write-Host "Find files that match: $args"
       gci -r | Where-Object { $_.name -match ".*$args.*" }
   }
  </code></pre>
  
  <p>doesn't seem to work.  For example,</p>
  
  <pre><code> findf .exe
  </code></pre>
  
  <p>-- Prints a bunch of stuff not limiting output to EXE files --</p>
  
  <p>Any ideas what I'm doing wrong?</p>
  
  <p>If I run the same command from the PowerShell command window the command works:</p>
  
  <pre><code> gci -r | Where-Object { $_.name -match ".*.exe.*" }
  </code></pre>
  
  <p>This works and correctly shows me the files that match the *.EXE pattern</p>