title: Powershell script to locate specific file/file name?
body: <p><strong>I wanted to write a small script that searched for an exact file name, not a string within a file name.</strong></p>
  
  <p>For instance if I search for 'hosts' using Explorer, I get multiple results by default. With the script I want ONLY the name I specify. I'm assuming that it's possible? </p>
  
  <p>I had only really started the script and it's only for my personal use so it's not important, it's just bugging me. I have several drives so I started with 2 inputs, one to query drive letter and another to specify file name. I can search by extension, file size etc but can't seem to pin the search down to an exact name.</p>
  
  <p>Any help would be appreciated!</p>
  
  <p>EDIT : Thanks to all responses. Just to update. I added one of the answers to my tiny script and it works well. All three responses worked but I could only use one ultimately, no offence to the other two. Cheers. Just to clarify, 'npp' is an alias for Notepad++ to open the file once found.</p>
  
  <pre><code>$drv = read-host "Choose drive"
  $fname = read-host "File name"
  $req = dir -Path $drv -r | Where-Object { !$PsIsContainer -and  [System.IO.Path]::GetFileNameWithoutExtension($_.Name) -eq $fname }
  set-location $req.directory
  npp $req
  </code></pre>