Thanks all I appreciate it. If I wanted to take this a bit further how would I accomplish the below?
Combine two arrays, do a compare on the arrays for matches and then remove an entry?
So using the previous example
$array1 = 1,2
$arra2 = 2,3,4
$array3 = $array1+$array2 | select -unique
Will return the 1,2,3,4
Then compare to another list of values
$masterlist = "1","4"
$matches = compare-object -referenceobject $array3 -differenceobject $masterlist -excludedifferent -includeequal | select -expand inputobject
I’ll now see a $matches = 1,4
but If I want to remove, say “4”, how would I do this?
If I use the Hashset, it lists all the items as one argument.
If I try
I get an error since the array is fixed and cannot be changed.
If I change the $master to a arraylist and try the .remove I still get an error?
I know i’m a bit out of my element here, but would appreciate any help.