I have stored file paths which match particular text which I am looking for, in a variable. Now, what I want to do is copy those files, which match content I'm looking for, and put them into a new folder.
I have written the following simple scripts, neither of which work:
(I)
Copy-Item -path $match in $filepaths -Destination C:\newfolder -Recurse
"a positional parameter cannot be found which accepts argument 'in'"
"ParametersBindingException"
"PositionalParameterNotFound"
(II)
foreach($match in $filepaths) { Copy-Item -path $match -Destination C:\newfolder }
Corresponding error message, showing for
each item in $filepaths:
"cannot find path"
Any ideas as to how to make them work?