I realize arrays are fixed-size collections. I am aware of how to manipulate their contents in various ways, change them into other array types, etc, but I can't figure out how to use the contents of one array to remove elements from another. For example, lets say we have this array:
$keep = "string1" , "string2" , "string3"
Then we build another array from something like a directory:
$collection = (get-childItem c:\directory1).Name
Now I want to make a third array by removing the three elements found in $keep from $collection:
$collection2 = $collection | Where-Object {$_.Name -ne $keep}
I cannot seem to get this to work. Lets just assume both of the first two arrays here are type object.