Copy list of files to folders depending on name with PowerShell

The -like operator uses wildcards, and will perform a full-length comparison:

"a" -like "a" # true
"ab" -like "a" # false

So if you want to test if one value contains another value, you have to put asterisks at the start and end of the wildcard string:

if ($key1 -like "*$key2*")

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top