Reputation: 141
I have a list of file Id's
and I want to find the system feed files containing any of these numbers from a vast directory using powershell.
I was using Get-Content Cash* -totalcount 1 > cash_Check_outputfile.txt
but as each file contains numerous headers this was not working as I hoped.
Can anyone point me in the right direction?
Much appreciated.
Upvotes: 2
Views: 1414
Reputation: 58961
Use the Get-ChildItem cmdlet to retrieve all files and use the Select-String cmdlet to find the files containing any number within your dictionary ($test
in this example). Finally, use the Select-Object cmdlet to get the path.
$test = @(
707839
709993
)
$pathToSearch = 'C:\test'
Get-ChildItem $pathToSearch | Select-String $test | Select-Object -ExpandProperty Path
Upvotes: 1