I have this string variable:
$path = "C:\Windows"
I have this array of strings:
$badDir = "windows",
"i3\ic",
"program",
"system",
"pagefile.sys",
"system",
"swapfile.sys",
"sourcecd",
"backup",
"wwwroot",
"users",
"desktop",
"documents"
I'm trying to evaluate if $path has any of the strings contained in the array $badDir anywhere in its value. E.g. since my $path value is C:\Windows, and one of the elements of my array is windows, "Windows" should be matched and the following evaluation should return true.
$badDir -Match $path.ToLower()
However, it's returning false. What am I doing incorrectly here?
Thanks!
C:\Someotherdir\Windows\Helloit would still return true.$path -match ($badDir -join '|')or similar? You ask to avoid using regular expressions, and then use-matchin your code, and-matchalways treats the thing on the right as a regular expression.