I have a simple program here that will write out a line within an array of lines if it does not contain any of the names within another array.
[array]$names = "Adam", "Bill", "Colin", "Dave"
[array]$lines = "My name is Jim", "My name is Sam", "My name is Adam"
foreach ($line in $lines)
{
if ($line -notmatch $names)
{
write $line
}
}
When I run this, it just writes out every line from the array of lines, even though 'Adam' is included in the array of names. It should just write out 'My name is Jim' and 'My name is Sam'.
Sorry if this question is pretty basic but I couldn't find any answers for it.