Is there a way to find if a file exists on a PC if you don't know the path?
I have a number of PCs that have a particular file on them lets call it "abc.exe" The problem is that the developer who built the install configured it to generate a random install directory. Is there a way I can search for the file using wildcards or just the entire C drive for example in my KACE System Managment Appliance?
Answers (2)
Step 1
You could have a Powershell script that either runs once or on a schedule depending on your needs. (in Kace or group policy)
Get-ChildItem 'C:\' -Filter 'abc.exe' -Recurse -ErrorAction SilentlyContinue | % { $_.FullName } | Out-File C:\Temp\abc.log
This will dump a log file containing all the entries into the temp folder.
Step 2
Then in Kace...
Go to Inventory > Software
Do 'Choose Action' - New
Enter a name (whatever you want to call it), assign to an operating system (do all Windows)
Under Custom inventory rule, enter the following:
ShellCommandTextReturn(cmd /c type "C:\Temp\abc.log")
After the script runs and that file exists, once the computers check into Kace that data will get sucked into Inventory > Devices under Custom Inventory Fields and you'll be able to see the location.
Note:
There may be a way to even skip the script step, and just to get this to run as a custom inventory rule in of itself. But it doesn't seem to be working when I tried.
ShellCommandTextReturn(cmd /q /c powershell.exe -command "Get-ChildItem 'C:\' -Filter 'abc.exe' -Recurse -ErrorAction SilentlyContinue | % { $_.FullName }")
Update:
This appears to work as just a custom inventory rule with no script step 1 required (should hit 32 and 64 bit folders, I think the original method was only hitting 32 bit folders due to agent being 32 bit)
ShellCommandTextReturn(cmd /q /c C:\windows\sysnative\WindowsPowerShell\v1.0\powershell.exe -command "Get-ChildItem 'C:\' -Filter 'abc.exe' -Recurse -ErrorAction SilentlyContinue | ForEach-Object {$_.FullName}")