I'm trying to find a single line of code recursively using powershell.
To look for the line "TODO" in a known file I can do:
get-content ActivityLibrary\Accept.cs | select-string TODO
But I don't want to explicitly type every directory\file. I would like to pipe a series of filenames from get-childitem like this:
gci -filter *.cs -name -recurse | gc | select-string TODO
But then I see this error:
Get-Content : The input object cannot be bound to any parameters for the comman d either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input. At line:1 char:37
What am I doing wrong?
You need to remove the -Name switch. It outputs just file names, not file objects. And you can also pipe directly to Select-String and drop 'gc'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With