how to search for a.bak files on all drives on multiple computers

i have 10 computeers and saved .bak files almost in all drives.

i am using below script to find .bak  but not getting the result.

#server.txt contains computer names

$comp=get-content d:servers.txt

foreach($comp in $comp)

$k=Get-ChildItem d:\*,c:\* -recurse -include *.bak

$k|select fullname | Export-Csv C:\files.csv -NoTypeInformation

please help me.............
siva kAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You're never accessing a remote machine.
Try this; it queries each local disk on the remote machines:
Get-Content -Path D:\servers.txt | ForEach-Object {
	$Server = $_
	"Processing $($Server)" | Write-Host
	Try {
		Get-WmiObject -Query "SELECT Name FROM Win32_LogicalDisk WHERE DriveType=3" -ComputerName $Server -ErrorAction Stop | ForEach-Object {
			"  - Drive $($_.Name)" | Write-Host
			Get-ChildItem "\\$($Server)\$($_.Name.Replace(':', '$'))" -Filter *.bak -Recurse -ErrorAction Continue |
				Select-Object -Property @{n='ComputerName'; e={$Server}}, @{n='DirectoryName'; e={$_.DirectoryName.Split('\', 4)[3].Replace('$', ':')}}, Name, Length, LastWriteTime
	} Catch {
		"Unable to access $($Server): $($_.Exception.Message)" | Write-Error
} | Export-Csv -Path C:\files.csv -NoTypeInformation

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Question answered.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.