I have a file with multiple words. I would like to get only those words, that contain the letters I passed as arguments to the program.
For example: test.txt
apple
car
computer
tree
./select.ps1 test.txt o e r
Result should be like:
computer
I wrote this:
foreach ( $line in $args[0] ) {
Get-Content $line | Select-String -Pattern $args[1] | Select-String -Pattern $args[2] | Select-String $args[3]
}
But what if I want to use for example 10 parameters and don't want to change my code all the time? How would I manage that?