Get powershell to display all paths where a specific file can be found on disk

I am trying to create a function that will show me the whole path where a specific file name is located. The function will take one parameter, which is the file name. The result will be either a list of all paths, or a message stating that the system does not have such a file.

I am new to Powershell and I am not getting the syntax yet. I tried this:

Get-ChildItem -Path -Include notepad.exe

But this caused an error message. I'm trying now:

$i="notepad.exe"

Foreach ($i in Get-ChildItem c:\ -Recurse){echo -Path}

To begin with, it is still working now, I don’t know what will happen, really.

EDIT: echo'd a huge number of lines that just say "-Path" ...

Can anyone help to solve this problem? By the way, I am running Powershell 1.0.

, , , , *.txt:

C:/foo.txt
C:/A/foobar.txt
:/A1/foo.txt

, .txt . , , .

EDIT2:

. , .

( .zip , , ):

Get-ChildItem -Path c:\ -Include "*.zip" -Recurse -Force -Name > c:\listOfPaths.txt

listOfPaths.txt C: \, , .zip .

"c: \" , .

EDIT3:

capar .

capar ( , Get-Children 1.0)

Get-ChildItem -Path c:\ -Recurse *.txt | Select-Object -Property FullName
+5
3

Power Shell, , :) , , :

Get-ChildItem -Path c:\ -Recurse *.txt | Select-Object -Property FullName

, , Get-ChildItem:

Get-ChildItem | Get-Member
+9

ls c:\-r |? {$ _. name -eq "notepad.exe" }

+1

Get-Children Powershell V3. , - .

As a warning to anyone looking for files: C: \ it will take a lot of time on today's hard drives. You are advised to narrow your search as you can. Since your folder structure may contain spaces or special characters, use typewriter quote metrics (") or apostrophes (').

$ mylistoffiles = Get-ChildItem -Path 'C: \ Windows \ Setup \ Scripts' -Recurse * .cmd | Select-Object -Property FullName

$ mylistoffiles

+1
source

All Articles