Search file name in all drive many computers

HI all,
I want to search particular file name in all drives in many computers
Shall I pass computer name in notepad and search all drives.
Can anyone share some script

Welcome to the forum. :wave:t4:

We do not deliver ready to use code or solutions on request. But we’d be happy to assist with code you wrote by yourself and just got stuck with. So if you already have some code to share please share it. :wink:

May I ask some more details about the task you want to achieve?

Most of the time you’re not the very first one with a given task. And your task sounds quite common. So there is a good chance for you to find quite a few examples for code like this already shared in the internet.

Thank you, I am new to PS. I have tried to export into excel of file found in - server, file name , path and version if possible.
I have only see parameter to pass -path , not sure how to search all drives.

$computerlist= get-content '\\share\DBA_team\Server.txt'
#write-host $computerlist
ForEach-Object {Get-ChildItem -Path C:\ -Recurse -Filter log4j*} |
Select-Object -Property HostName

I’m afraid you misunderstood something about the vulnerability log4shell. There won’t likely be a file with the name log4j* even if you run software using the vulnerable library.

I’d recommend to read more about here:

If you would like to scan your servers anyway for the given file name pattern you could use soemthing like this:

$computerlist = Get-Content -Path '\\share\DBA_team\Server.txt'
Invoke-Command -ComputerName $computerlist -ScriptBlock {
    Get-CimInstance -ClassName Win32_logicaldisk -Filter "DriveType =3" |
        ForEach-Object {
            Get-ChildItem -Path $_.DeviceID -Filter log4j* -File -Recurse -Force -ErrorAction SilentlyContinue

cd \
dir /s /b server.txt

Although that is a nice quick search, it can be done on one line:

dir c:\server.txt /s /b

Olaf’s method returns objects which can be easier to deal with in PS.

Just my $.02.

Since this is a PowerShell forum I’d consider this as a really bad advice. :face_with_raised_eyebrow:

In PowerShell it throws an error and in CMD it does not do what the OP asked. :-1:t4:

Wasn’t my advice, I just pointed out yours was better :slight_smile: