I wish to move the files from Source to Destination based on a wildcard match from each string in FileNames.txt.
The following is code similar to what I want to achieve, however it is meant for a single string rather than the contents of a text file so it fails when passing it the variable $FileNamesToMatch:
Your issue is that you’re passing the entire thing into the parameter and putting wildcards around it. You need wildcards on every entry. The string -Filter gets would end up something like this:
You can probably remove the $FileNamesToMatch variable, really, it won’t hold that much of use. It’ll end up just storing the references to the moved objects, so if you need those, awesome, but if not you can just have that bit be:
New to PoSH, means be sure to look to these resources to get a firm start / understanding of the whys and wherefors.
Well, that and to save yourself a good deal of unnecessary frustration.