Im able to compare to arrays and get the index of an element, but this built in Compare-Object function is returning a strange value. When I run this code it returns the value of -1.
This is my code.
# compare to arrays
$array1 = @(1,2,3,4,5)
$array2 = @(1,2,7,4,5)
$difference = Compare-Object $array1 $array2
# get the position of the difference in arrays
[array]::IndexOf($array1, $difference)
[array]::IndexOf($array2, $difference)
Result
PS C:\...\2017-06-25> C:\...\2017-06-25\compareArrays.ps1
-1
-1
Im going to use this to read to files and compare them and tell me where in the file the differences are.