$test_array = @('one', 'two', 'three')
foreach ($entry in $test_array) {
Write-Host $entry -BackgroundColor Red
$test = Compare-Object -DifferenceObject $entry -ReferenceObject $entry -IncludeEqual
$test
}
I have this code above. What I expect is that the result of Compare-Object appears under each entry of the array.
one
InputObject SideIndicator
----------- -------------
one ==
two
InputObject SideIndicator
----------- -------------
two ==
three
InputObject SideIndicator
----------- -------------
three ==
What gets output instead is this:
one
two
three
InputObject SideIndicator
----------- -------------
one ==
two ==
three ==
It skips every entry and outputs the result of everything in the end together. Why does this happen? I'm on Powershell 5.1