The lines such as [test group2] contains [test group1] and [test group1] contains [test group2] are essentially duplicates, just in a different order. I really only need one or the other, not important which I keep.
How could I go about clearing out any duplicates from the array?
So the same would be true for [test group2] contains [test group3] and [test group3] contains [test group2], correct? If so you could just use a switch utilizing regex with a list and only add to the list if both don’t already exist in a line. It’s a lot easier to show than express with words so please see the example.
To simulate a Get-Content $somefile we’ll use a here-string split at new lines. Then we’ll prepare an empty list and finally process each line through the switch.